程序风格:空格与回车 -- 感谢Hold

本文讲述了良好的程序风格对于代码可读性的提升作用。作者通过实践发现,在关键字和操作符两侧添加适当的空格能够显著提高代码的整洁度。这种简洁的代码风格不仅让读者易于理解,还能提升整体项目的美观。

良好的程序风格其实是由一系列在恰当位置出现的空格或者回车(除comments外),它们丰富了代码的视觉空间;风格良好的代码能够让阅者眼前一亮,继而心旷神怡地阅读下去。

不知道什么时候,我学会了用大量的回车使我的代码更加清晰,但是不知道为什么,看着还是觉得有点乱麻,直到若干天之前,hold同学指出了我代码风格的缺陷,我才知道原来就是少那么几个空格--关键字以及操作符两边的空格。

然后,整个代码清静了....

sudo wpa_supplicant -d -Dnl80211 -i wlan0 -c /etc/wpa_supplicant_rtl.conf wpa_supplicant v2.10 random: Trying to read entropy from /dev/random Successfully initialized wpa_supplicant Initializing interface 'wlan0' conf '/etc/wpa_supplicant_rtl.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A' Configuration file '/etc/wpa_supplicant_rtl.conf' -> '/etc/wpa_supplicant_rtl.conf' Reading configuration file '/etc/wpa_supplicant_rtl.conf' nl80211: Supported cipher 00-0f-ac:1 nl80211: Supported cipher 00-0f-ac:5 nl80211: Supported cipher 00-0f-ac:2 nl80211: Supported cipher 00-0f-ac:4 nl80211: Supported cipher 00-0f-ac:6 nl80211: Using driver-based off-channel TX nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x800d0c0 rrm_flags=0x0 probe_resp_offloads=0x0 max_stations=0 max_remain_on_chan=5000 max_scan_ssids=9 nl80211: interface wlan0 in phy phy0 nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Subscribe to mgmt frames with non-AP handle 0x50be78 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=0801 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=06 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=0a07 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=0a11 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=1101 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=1102 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=0505 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=0500 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=1301 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=1305 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x50be78 match=7e506f9a1a multicast=0 rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0 netlink: Operstate: ifindex=2 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT) Add interface wlan0 to a new radio phy0 nl80211: Regulatory information - country=00 nl80211: 2402-2472 @ 40 MHz 20 mBm nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR) nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR) nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR) nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR) nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR) nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR) nl80211: 57240-63720 @ 2160 MHz 0 mBm nl80211: Added 802.11b mode based on 802.11g information nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED] nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED] wlan0: Own MAC address: cc:b8:5e:f5:a6:86 wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key
06-10
# uinput too few arguments to function Usage: uinput <option> <command> <arg>... The option are: -K --keyboard commands for keyboard: -d <key> --down <key> -press down a key -u <key> --up <key> -release a key -l <key> [long press time] --long_press <key> [long press time] -press and hold the key -r <key> [repeat output time] --repeat output <key> [repeat output time] -press and hold the key -i <time> --interval <time> -the program interval for the (time) milliseconds -t <text> --text <text> -input text content. The text command cannot be used with other commands. -M --mouse commands for mouse: -m <dx> <dy> --move <dx> <dy> -move to relative position (dx,dy), <dx1> <dy1> <dx2> <dy2> [smooth time] --trace -dx1 dy1 to dx2 dy2 smooth movement -d <key> --down key -press down a button, 0 is the left button, 1 is the right, 2 is the middle -u <key> --up <key> -release a button -c <key> --click <key> -press the left button down,then raise -b <dx1> <dy1> <id> [press time] [click interval time] --double click [press time] the time range is more than 1ms but less than 300ms, [click interval time] the time range is more than 1ms but less than 450ms, Otherwise the operation result may produce error or invalid operation -press the left button down,then raise key value:0 - button left key value:1 - button right key value:2 - button middle key value:3 - button side key value:4 - button extra key value:5 - button forward key value:6 - button back key value:7 - button task -s <key> --scroll <key> -positive values are sliding backwards -g <dx1> <dy1> <dx2> <dy2> [total time] --drag <dx1> <dy1> <dx2> <dy2> [total time], dx1 dy1 to dx2 dy2 smooth drag -i <time> --interval <time> -the program interval for the (time) milliseconds negative values are sliding forwards -P --touchpad commands for touchpad: -p dx, dy, scalePercent; dx, dy, scalePercent are all number. dx is bigger than 0 and dy is bigger than 200. 0 < scalePercent < 500; While simulate this, make sure that a picture is on the top of the desktop. -s startX, startY, endX, endY; And startX, startY, endX, endY are all number which is bigger than 0; While simulate this, make sure that your actual action is available -r <rotate value> rotate value must be within (-360,360) -S --stylus commands for stylus: -d <dx1> <dy1> --down <dx1> <dy1> -press down a position dx1 dy1, -u <dx1> <dy1> --up <dx1> <dy1> -release a position dx1 dy1, -i <time> --interval <time> -the program interval for the (time) milliseconds -m <dx1> <dy1> <dx2> <dy2> [smooth time] --smooth movement <dx1> <dy1> <dx2> <dy2> [smooth time] -smooth movement, dx1 dy1 to dx2 dy2 smooth movement -c <dx1> <dy1> [click interval] -touch screen click dx1 dy1 -g <dx1> <dy1> <dx2> <dy2> [press time] [total time] -drag, [Press time] not less than 500ms and [total time] - [Press time] not less than 500ms Otherwise the operation result may produce error or invalid operation -T --touch commands for touch: -d <dx1> <dy1> --down <dx1> <dy1> -press down a position dx1 dy1, -u <dx1> <dy1> --up <dx1> <dy1> -release a position dx1 dy1, -i <time> --interval <time> -the program interval for the (time) milliseconds -m <dx1> <dy1> <dx2> <dy2> [-k keep time] [smooth time] --smooth movement, keep time:keep time after moving, the max value is 60000 ms, default value is 0; smooth time: move time, default value is 1000 ms, the max value is 15000 ms Supports up to three finger movement at the same time, for example: uinput -T -m 300 900 600 900 900 900 600 900, (300, 900) move to (600, 900), (900, 900) move to (600, 900) -c <dx1> <dy1> [click interval] -touch screen click dx1 dy1 -k --knuckle commands for knucle: -s <dx1> <dy1> <dx2> <dy2> [interval time] --single knuckle double click interval time -d <dx1> <dy1> <dx2> <dy2> [interval time] --double knuckle double click interval time -i <time> --interval <time> -the program interval for the (time) milliseconds -g <dx1> <dy1> <dx2> <dy2> [press time] [total time] -drag, [Press time] not less than 500ms and [total time] - [Press time] not less than 500ms Otherwise the operation result may produce error or invalid operation 如何往文本框输入字符
12-02
在数字化环境中,线上票务获取已成为参各类活动的主要途径。随着公众对热门演出需求的增长,票源往往在开放销售后迅速告罄,导致普通消费者难以顺利购得所需票券。为应对这一挑战,部分技术开发者借助编程手段构建了自动化购票辅助程序,旨在提升用户成功获取门票的概率。本文将以一个针对特定票务平台设计的自动化工具为例,系统阐述其设计理念、技术组成及具体实施流程。 秀动网作为国内知名的演出及体育赛事票务销售平台,因活动热度较高,常出现访问拥堵、瞬时抢购压力大等现象,使得常规购票过程面临困难。因此,开发一款能够协助用户更有效完成票务申购的辅助工具具有实际意义。 该工具主要具备以下几项关键功能:持续监控目标平台的票务信息更新;在票务释放时自动执行选座、添加至购物车及提交订单等系列操作;集成一定的异常处理机制,以应对网络延迟或服务器响应异常等情况。 在技术实现层面,选用Python作为开发语言,主要基于其语法简洁、标准库第三方资源丰富,适合快速构建功能原型。同时,Python在网络通信浏览器自动化方面拥有如requests、selenium等成熟支持库,为程序实现网页交互数据抓取提供了便利。 开发过程主要包括以下环节:首先解析目标网站的页面结构,明确可通过程序操控的网页元素路径;随后编写监控模块,实时检测新票务信息的上线并及时触发后续操作;接着模拟用户操作流程,包括自动填写个人信息、选择座位偏好、完成购物车添加等步骤,并通过行为模拟降低被平台反爬虫机制识别的可能;最终实现订单自动提交,并在成功购票后向用户发送通知。 此外,该工具提供了可配置的操作界面,允许用户根据个人需求设定抢票时间、目标活动类型及座位选择等参数,从而在提升使用体验的同时,减少对票务平台服务器资源的非必要占用。 需指出的是,尽管此类工具能提高购票效率,但其使用可能涉及违反平台服务协议或相关法规的风险。各票务销售方通常对自动化抢票行为设有明确约束,因此开发使用者均应遵守相应规定,确保技术应用的合法性。 综上所述,该基于Python的票务辅助工具是针对特定场景设计的自动化解决方案,通过技术手段改善用户购票体验,但同时也强调必须在法律平台规则框架内合理使用此类技术。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值