Python从入门到精通_第1课_入门基础_笔记

Dear 丶 2021-11-17 23:16 427阅读 0赞

文章目录

  • Python简介
  • 为什么选择Python
  • 环境搭建
  • 如何学好编程
  • 常用关键字
  • 基本运算符
  • 基本语法

GitHub: https://github.com/RealEmperor/Basic-Introductory-Python-Course

Python简介

Python 是一种易于学习又功能强大的编程语言。它提供了高效的高级数据结构,还有简单有效的面向对象编程。Python 优雅的语法和动态类型,以及解释型语言的本质,使它成为多数平台上写脚本和快速开发应用的理想语言。

Python 解释器及丰富的标准库以源码或机器码的形式提供,可以到 Python 官网 https://www.python.org/ 免费获取适用于各个主要系统平台的版本,并可自由地分发。这个网站还包含许多免费第三方 Python 模块、程序和工具以及附加文档的发布页面或链接。

Python 解释器易于扩展,可以使用 C 或 C++(或者其他可以通过 C 调用的语言)扩展新的功能和数据类型。Python 也可用于可定制化软件中的扩展程序语言。
来源:https://docs.python.org/zh-cn/3/tutorial/index.html

为什么选择Python

Python很强大(略)

环境搭建

推荐使用安装Anaconda,大部分我们要用到的库都有了,官网:https://www.anaconda.com/

IDE推荐使用PyCharm,具体的安装办法网上很多。

如何学好编程

仁者见仁智者见智,多看,多写

最新的Python中文文档在这里:
https://docs.python.org/zh-cn/3/

常用关键字

  1. help("keywords")
  2. Here is a list of the Python keywords. Enter any keyword to get more help.
  3. False def if raise
  4. None del import return
  5. True elif in try
  6. and else is while
  7. as except lambda with
  8. assert finally nonlocal yield
  9. break for not
  10. class from or
  11. continue global pass

help([object])
启动内置的帮助系统(此函数主要在交互式中使用)。如果没有实参,解释器控制台里会启动交互式帮助系统。如果实参是一个字符串,则在模块、函数、类、方法、关键字或文档主题中搜索该字符串,并在控制台上打印帮助信息。如果实参是其他任意对象,则会生成该对象的帮助页。
来源:https://docs.python.org/zh-cn/3/library/functions.html#help

  1. # help的更多例子:
  2. # 查看Python所有的modules:
  3. help('modules')
  4. # 查看Python中的topics:
  5. help('topics')
  6. Here is a list of available topics. Enter any topic name to get more help.
  7. ASSERTION DELETION LOOPING SHIFTING
  8. ASSIGNMENT DICTIONARIES MAPPINGMETHODS SLICINGS
  9. ATTRIBUTEMETHODS DICTIONARYLITERALS MAPPINGS SPECIALATTRIBUTES
  10. ATTRIBUTES DYNAMICFEATURES METHODS SPECIALIDENTIFIERS
  11. AUGMENTEDASSIGNMENT ELLIPSIS MODULES SPECIALMETHODS
  12. BASICMETHODS EXCEPTIONS NAMESPACES STRINGMETHODS
  13. BINARY EXECUTION NONE STRINGS
  14. BITWISE EXPRESSIONS NUMBERMETHODS SUBSCRIPTS
  15. BOOLEAN FLOAT NUMBERS TRACEBACKS
  16. CALLABLEMETHODS FORMATTING OBJECTS TRUTHVALUE
  17. CALLS FRAMEOBJECTS OPERATORS TUPLELITERALS
  18. CLASSES FRAMES PACKAGES TUPLES
  19. CODEOBJECTS FUNCTIONS POWER TYPEOBJECTS
  20. COMPARISON IDENTIFIERS PRECEDENCE TYPES
  21. COMPLEX IMPORTING PRIVATENAMES UNARY
  22. CONDITIONAL INTEGER RETURNING UNICODE
  23. CONTEXTMANAGERS LISTLITERALS SCOPING
  24. CONVERSIONS LISTS SEQUENCEMETHODS
  25. DEBUGGING LITERALS SEQUENCES
  26. # 查看Python所有的modules中包含指定字符串的modules:
  27. help("modules zlib")
  28. Here is a list of modules whose name or summary contains 'zlib'.
  29. If there are any, enter a module name to get more help.
  30. zlib - The functions in this module allow compression and decompression using the
  31. encodings.zlib_codec - Python 'zlib_codec' Codec - zlib compression encoding.
  32. test.test_zlib
  33. # 查看Python库中的module:
  34. import time
  35. help(time)
  36. Help on built-in module time:
  37. NAME
  38. time - This module provides various functions to manipulate time values.
  39. DESCRIPTION
  40. There are two standard representations of time. One is the number
  41. of seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer
  42. or a floating point number (to represent fractions of seconds).
  43. The Epoch is system-defined; on Unix, it is generally January 1st, 1970.
  44. The actual value can be retrieved by calling gmtime(0).
  45. The other representation is a tuple of 9 integers giving local time.
  46. The tuple items are:
  47. year (including century, e.g. 1998)
  48. month (1-12)
  49. day (1-31)
  50. hours (0-23)
  51. minutes (0-59)
  52. seconds (0-59)
  53. weekday (0-6, Monday is 0)
  54. Julian day (day in the year, 1-366)
  55. DST (Daylight Savings Time) flag (-1, 0 or 1)
  56. If the DST flag is 0, the time is given in the regular time zone;
  57. if it is 1, the time is given in the DST time zone;
  58. if it is -1, mktime() should guess based on the date and time.
  59. Variables:
  60. timezone -- difference in seconds between UTC and local standard time
  61. altzone -- difference in seconds between UTC and local DST time
  62. daylight -- whether local time should reflect DST
  63. tzname -- tuple of (standard time zone name, DST time zone name)
  64. Functions:
  65. time() -- return current time in seconds since the Epoch as a float
  66. clock() -- return CPU time since process start as a float
  67. sleep() -- delay for a number of seconds given as a float
  68. gmtime() -- convert seconds since Epoch to UTC tuple
  69. localtime() -- convert seconds since Epoch to local time tuple
  70. asctime() -- convert time tuple to string
  71. ctime() -- convert time in seconds to string
  72. mktime() -- convert local time tuple to seconds since Epoch
  73. strftime() -- convert time tuple to string according to format specification
  74. strptime() -- parse string to time tuple according to format specification
  75. tzset() -- change the local timezone
  76. CLASSES
  77. builtins.tuple(builtins.object)
  78. struct_time
  79. class struct_time(builtins.tuple)
  80. | The time value as returned by gmtime(), localtime(), and strptime(), and
  81. | accepted by asctime(), mktime() and strftime(). May be considered as a
  82. | sequence of 9 integers.
  83. |
  84. | Note that several fields' values are not the same as those defined by
  85. | the C language standard for struct tm. For example, the value of the
  86. | field tm_year is the actual year, not year - 1900. See individual
  87. | fields' descriptions for details.
  88. |
  89. | Method resolution order:
  90. | struct_time
  91. | builtins.tuple
  92. | builtins.object
  93. |
  94. | Methods defined here:
  95. |
  96. | __new__(*args, **kwargs) from builtins.type
  97. | Create and return a new object. See help(type) for accurate signature.
  98. |
  99. | __reduce__(...)
  100. | helper for pickle
  101. |
  102. | __repr__(self, /)
  103. | Return repr(self).
  104. |
  105. | ----------------------------------------------------------------------
  106. | Data descriptors defined here:
  107. |
  108. | tm_gmtoff
  109. | offset from UTC in seconds
  110. |
  111. | tm_hour
  112. | hours, range [0, 23]
  113. |
  114. | tm_isdst
  115. | 1 if summer time is in effect, 0 if not, and -1 if unknown
  116. |
  117. | tm_mday
  118. | day of month, range [1, 31]
  119. |
  120. | tm_min
  121. | minutes, range [0, 59]
  122. |
  123. | tm_mon
  124. | month of year, range [1, 12]
  125. |
  126. | tm_sec
  127. | seconds, range [0, 61])
  128. |
  129. | tm_wday
  130. | day of week, range [0, 6], Monday is 0
  131. |
  132. | tm_yday
  133. | day of year, range [1, 366]
  134. |
  135. | tm_year
  136. | year, for example, 1993
  137. |
  138. | tm_zone
  139. | abbreviation of timezone name
  140. |
  141. | ----------------------------------------------------------------------
  142. | Data and other attributes defined here:
  143. |
  144. | n_fields = 11
  145. |
  146. | n_sequence_fields = 9
  147. |
  148. | n_unnamed_fields = 0
  149. |
  150. | ----------------------------------------------------------------------
  151. | Methods inherited from builtins.tuple:
  152. |
  153. | __add__(self, value, /)
  154. | Return self+value.
  155. |
  156. | __contains__(self, key, /)
  157. | Return key in self.
  158. |
  159. | __eq__(self, value, /)
  160. | Return self==value.
  161. |
  162. | __ge__(self, value, /)
  163. | Return self>=value.
  164. |
  165. | __getattribute__(self, name, /)
  166. | Return getattr(self, name).
  167. |
  168. | __getitem__(self, key, /)
  169. | Return self[key].
  170. |
  171. | __getnewargs__(...)
  172. |
  173. | __gt__(self, value, /)
  174. | Return self>value.
  175. |
  176. | __hash__(self, /)
  177. | Return hash(self).
  178. |
  179. | __iter__(self, /)
  180. | Implement iter(self).
  181. |
  182. | __le__(self, value, /)
  183. | Return self<=value.
  184. |
  185. | __len__(self, /)
  186. | Return len(self).
  187. |
  188. | __lt__(self, value, /)
  189. | Return self<value.
  190. |
  191. | __mul__(self, value, /)
  192. | Return self*value.n
  193. |
  194. | __ne__(self, value, /)
  195. | Return self!=value.
  196. |
  197. | __rmul__(self, value, /)
  198. | Return self*value.
  199. |
  200. | count(...)
  201. | T.count(value) -> integer -- return number of occurrences of value
  202. |
  203. | index(...)
  204. | T.index(value, [start, [stop]]) -> integer -- return first index of value.
  205. | Raises ValueError if the value is not present.
  206. FUNCTIONS
  207. asctime(...)
  208. asctime([tuple]) -> string
  209. Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
  210. When the time tuple is not present, current time as returned by localtime()
  211. is used.
  212. clock(...)
  213. clock() -> floating point number
  214. Return the CPU time or real time since the start of the process or since
  215. the first call to clock(). This has as much precision as the system
  216. records.
  217. ctime(...)
  218. ctime(seconds) -> string
  219. Convert a time in seconds since the Epoch to a string in local time.
  220. This is equivalent to asctime(localtime(seconds)). When the time tuple is
  221. not present, current time as returned by localtime() is used.
  222. get_clock_info(...)
  223. get_clock_info(name: str) -> dict
  224. Get information of the specified clock.
  225. gmtime(...)
  226. gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,
  227. tm_sec, tm_wday, tm_yday, tm_isdst)
  228. Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.
  229. GMT). When 'seconds' is not passed in, convert the current time instead.
  230. If the platform supports the tm_gmtoff and tm_zone, they are available as
  231. attributes only.
  232. localtime(...)
  233. localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
  234. tm_sec,tm_wday,tm_yday,tm_isdst)
  235. Convert seconds since the Epoch to a time tuple expressing local time.
  236. When 'seconds' is not passed in, convert the current time instead.
  237. mktime(...)
  238. mktime(tuple) -> floating point number
  239. Convert a time tuple in local time to seconds since the Epoch.
  240. Note that mktime(gmtime(0)) will not generally return zero for most
  241. time zones; instead the returned value will either be equal to that
  242. of the timezone or altzone attributes on the time module.
  243. monotonic(...)
  244. monotonic() -> float
  245. Monotonic clock, cannot go backward.
  246. perf_counter(...)
  247. perf_counter() -> float
  248. Performance counter for benchmarking.
  249. process_time(...)
  250. process_time() -> float
  251. Process time for profiling: sum of the kernel and user-space CPU time.
  252. sleep(...)
  253. sleep(seconds)
  254. Delay execution for a given number of seconds. The argument may be
  255. a floating point number for subsecond precision.
  256. strftime(...)
  257. strftime(format[, tuple]) -> string
  258. Convert a time tuple to a string according to a format specification.
  259. See the library reference manual for formatting codes. When the time tuple
  260. is not present, current time as returned by localtime() is used.
  261. Commonly used format codes:
  262. %Y Year with century as a decimal number.
  263. %m Month as a decimal number [01,12].
  264. %d Day of the month as a decimal number [01,31].
  265. %H Hour (24-hour clock) as a decimal number [00,23].
  266. %M Minute as a decimal number [00,59].
  267. %S Second as a decimal number [00,61].
  268. %z Time zone offset from UTC.
  269. %a Locale's abbreviated weekday name.
  270. %A Locale's full weekday name.
  271. %b Locale's abbreviated month name.
  272. %B Locale's full month name.
  273. %c Locale's appropriate date and time representation.
  274. %I Hour (12-hour clock) as a decimal number [01,12].
  275. %p Locale's equivalent of either AM or PM.
  276. Other codes may be available on your platform. See documentation for
  277. the C library strftime function.
  278. strptime(...)
  279. strptime(string, format) -> struct_time
  280. Parse a string to a time tuple according to a format specification.
  281. See the library reference manual for formatting codes (same as
  282. strftime()).
  283. Commonly used format codes:
  284. %Y Year with century as a decimal number.
  285. %m Month as a decimal number [01,12].
  286. %d Day of the month as a decimal number [01,31].
  287. %H Hour (24-hour clock) as a decimal number [00,23].
  288. %M Minute as a decimal number [00,59].
  289. %S Second as a decimal number [00,61].
  290. %z Time zone offset from UTC.
  291. %a Locale's abbreviated weekday name.
  292. %A Locale's full weekday name.
  293. %b Locale's abbreviated month name.
  294. %B Locale's full month name.
  295. %c Locale's appropriate date and time representation.
  296. %I Hour (12-hour clock) as a decimal number [01,12].
  297. %p Locale's equivalent of either AM or PM.
  298. Other codes may be available on your platform. See documentation for
  299. the C library strftime function.
  300. time(...)
  301. time() -> floating point number
  302. Return the current time in seconds since the Epoch.
  303. Fractions of a second may be present if the system clock provides them.
  304. DATA
  305. altzone = -32400
  306. daylight = 0
  307. timezone = -28800
  308. tzname = ('Öйú±ê׼ʱ¼ä', 'ÖйúÏÄÁîʱ')
  309. FILE
  310. (built-in)
  311. help('time') # 字符串和上面效果一致
  312. Help on built-in module time:
  313. NAME
  314. time - This module provides various functions to manipulate time values.
  315. DESCRIPTION
  316. There are two standard representations of time. One is the number
  317. of seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer
  318. or a floating point number (to represent fractions of seconds).
  319. The Epoch is system-defined; on Unix, it is generally January 1st, 1970.
  320. The actual value can be retrieved by calling gmtime(0).
  321. The other representation is a tuple of 9 integers giving local time.
  322. The tuple items are:
  323. year (including century, e.g. 1998)
  324. month (1-12)
  325. day (1-31)
  326. hours (0-23)
  327. minutes (0-59)
  328. seconds (0-59)
  329. weekday (0-6, Monday is 0)
  330. Julian day (day in the year, 1-366)
  331. DST (Daylight Savings Time) flag (-1, 0 or 1)
  332. If the DST flag is 0, the time is given in the regular time zone;
  333. if it is 1, the time is given in the DST time zone;
  334. if it is -1, mktime() should guess based on the date and time.
  335. Variables:
  336. timezone -- difference in seconds between UTC and local standard time
  337. altzone -- difference in seconds between UTC and local DST time
  338. daylight -- whether local time should reflect DST
  339. tzname -- tuple of (standard time zone name, DST time zone name)
  340. Functions:
  341. time() -- return current time in seconds since the Epoch as a float
  342. clock() -- return CPU time since process start as a float
  343. sleep() -- delay for a number of seconds given as a float
  344. gmtime() -- convert seconds since Epoch to UTC tuple
  345. localtime() -- convert seconds since Epoch to local time tuple
  346. asctime() -- convert time tuple to string
  347. ctime() -- convert time in seconds to string
  348. mktime() -- convert local time tuple to seconds since Epoch
  349. strftime() -- convert time tuple to string according to format specification
  350. strptime() -- parse string to time tuple according to format specification
  351. tzset() -- change the local timezone
  352. CLASSES
  353. builtins.tuple(builtins.object)
  354. struct_time
  355. class struct_time(builtins.tuple)
  356. | The time value as returned by gmtime(), localtime(), and strptime(), and
  357. | accepted by asctime(), mktime() and strftime(). May be considered as a
  358. | sequence of 9 integers.
  359. |
  360. | Note that several fields' values are not the same as those defined by
  361. | the C language standard for struct tm. For example, the value of the
  362. | field tm_year is the actual year, not year - 1900. See individual
  363. | fields' descriptions for details.
  364. |
  365. | Method resolution order:
  366. | struct_time
  367. | builtins.tuple
  368. | builtins.object
  369. |
  370. | Methods defined here:
  371. |
  372. | __new__(*args, **kwargs) from builtins.type
  373. | Create and return a new object. See help(type) for accurate signature.
  374. |
  375. | __reduce__(...)
  376. | helper for pickle
  377. |
  378. | __repr__(self, /)
  379. | Return repr(self).
  380. |
  381. | ----------------------------------------------------------------------
  382. | Data descriptors defined here:
  383. |
  384. | tm_gmtoff
  385. | offset from UTC in seconds
  386. |
  387. | tm_hour
  388. | hours, range [0, 23]
  389. |
  390. | tm_isdst
  391. | 1 if summer time is in effect, 0 if not, and -1 if unknown
  392. |
  393. | tm_mday
  394. | day of month, range [1, 31]
  395. |
  396. | tm_min
  397. | minutes, range [0, 59]
  398. |
  399. | tm_mon
  400. | month of year, range [1, 12]
  401. |
  402. | tm_sec
  403. | seconds, range [0, 61])
  404. |
  405. | tm_wday
  406. | day of week, range [0, 6], Monday is 0
  407. |
  408. | tm_yday
  409. | day of year, range [1, 366]
  410. |
  411. | tm_year
  412. | year, for example, 1993
  413. |
  414. | tm_zone
  415. | abbreviation of timezone name
  416. |
  417. | ----------------------------------------------------------------------
  418. | Data and other attributes defined here:
  419. |
  420. | n_fields = 11
  421. |
  422. | n_sequence_fields = 9
  423. |
  424. | n_unnamed_fields = 0
  425. |
  426. | ----------------------------------------------------------------------
  427. | Methods inherited from builtins.tuple:
  428. |
  429. | __add__(self, value, /)
  430. | Return self+value.
  431. |
  432. | __contains__(self, key, /)
  433. | Return key in self.
  434. |
  435. | __eq__(self, value, /)
  436. | Return self==value.
  437. |
  438. | __ge__(self, value, /)
  439. | Return self>=value.
  440. |
  441. | __getattribute__(self, name, /)
  442. | Return getattr(self, name).
  443. |
  444. | __getitem__(self, key, /)
  445. | Return self[key].
  446. |
  447. | __getnewargs__(...)
  448. |
  449. | __gt__(self, value, /)
  450. | Return self>value.
  451. |
  452. | __hash__(self, /)
  453. | Return hash(self).
  454. |
  455. | __iter__(self, /)
  456. | Implement iter(self).
  457. |
  458. | __le__(self, value, /)
  459. | Return self<=value.
  460. |
  461. | __len__(self, /)
  462. | Return len(self).
  463. |
  464. | __lt__(self, value, /)
  465. | Return self<value.
  466. |
  467. | __mul__(self, value, /)
  468. | Return self*value.n
  469. |
  470. | __ne__(self, value, /)
  471. | Return self!=value.
  472. |
  473. | __rmul__(self, value, /)
  474. | Return self*value.
  475. |
  476. | count(...)
  477. | T.count(value) -> integer -- return number of occurrences of value
  478. |
  479. | index(...)
  480. | T.index(value, [start, [stop]]) -> integer -- return first index of value.
  481. | Raises ValueError if the value is not present.
  482. FUNCTIONS
  483. asctime(...)
  484. asctime([tuple]) -> string
  485. Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
  486. When the time tuple is not present, current time as returned by localtime()
  487. is used.
  488. clock(...)
  489. clock() -> floating point number
  490. Return the CPU time or real time since the start of the process or since
  491. the first call to clock(). This has as much precision as the system
  492. records.
  493. ctime(...)
  494. ctime(seconds) -> string
  495. Convert a time in seconds since the Epoch to a string in local time.
  496. This is equivalent to asctime(localtime(seconds)). When the time tuple is
  497. not present, current time as returned by localtime() is used.
  498. get_clock_info(...)
  499. get_clock_info(name: str) -> dict
  500. Get information of the specified clock.
  501. gmtime(...)
  502. gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,
  503. tm_sec, tm_wday, tm_yday, tm_isdst)
  504. Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.
  505. GMT). When 'seconds' is not passed in, convert the current time instead.
  506. If the platform supports the tm_gmtoff and tm_zone, they are available as
  507. attributes only.
  508. localtime(...)
  509. localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
  510. tm_sec,tm_wday,tm_yday,tm_isdst)
  511. Convert seconds since the Epoch to a time tuple expressing local time.
  512. When 'seconds' is not passed in, convert the current time instead.
  513. mktime(...)
  514. mktime(tuple) -> floating point number
  515. Convert a time tuple in local time to seconds since the Epoch.
  516. Note that mktime(gmtime(0)) will not generally return zero for most
  517. time zones; instead the returned value will either be equal to that
  518. of the timezone or altzone attributes on the time module.
  519. monotonic(...)
  520. monotonic() -> float
  521. Monotonic clock, cannot go backward.
  522. perf_counter(...)
  523. perf_counter() -> float
  524. Performance counter for benchmarking.
  525. process_time(...)
  526. process_time() -> float
  527. Process time for profiling: sum of the kernel and user-space CPU time.
  528. sleep(...)
  529. sleep(seconds)
  530. Delay execution for a given number of seconds. The argument may be
  531. a floating point number for subsecond precision.
  532. strftime(...)
  533. strftime(format[, tuple]) -> string
  534. Convert a time tuple to a string according to a format specification.
  535. See the library reference manual for formatting codes. When the time tuple
  536. is not present, current time as returned by localtime() is used.
  537. Commonly used format codes:
  538. %Y Year with century as a decimal number.
  539. %m Month as a decimal number [01,12].
  540. %d Day of the month as a decimal number [01,31].
  541. %H Hour (24-hour clock) as a decimal number [00,23].
  542. %M Minute as a decimal number [00,59].
  543. %S Second as a decimal number [00,61].
  544. %z Time zone offset from UTC.
  545. %a Locale's abbreviated weekday name.
  546. %A Locale's full weekday name.
  547. %b Locale's abbreviated month name.
  548. %B Locale's full month name.
  549. %c Locale's appropriate date and time representation.
  550. %I Hour (12-hour clock) as a decimal number [01,12].
  551. %p Locale's equivalent of either AM or PM.
  552. Other codes may be available on your platform. See documentation for
  553. the C library strftime function.
  554. strptime(...)
  555. strptime(string, format) -> struct_time
  556. Parse a string to a time tuple according to a format specification.
  557. See the library reference manual for formatting codes (same as
  558. strftime()).
  559. Commonly used format codes:
  560. %Y Year with century as a decimal number.
  561. %m Month as a decimal number [01,12].
  562. %d Day of the month as a decimal number [01,31].
  563. %H Hour (24-hour clock) as a decimal number [00,23].
  564. %M Minute as a decimal number [00,59].
  565. %S Second as a decimal number [00,61].
  566. %z Time zone offset from UTC.
  567. %a Locale's abbreviated weekday name.
  568. %A Locale's full weekday name.
  569. %b Locale's abbreviated month name.
  570. %B Locale's full month name.
  571. %c Locale's appropriate date and time representation.
  572. %I Hour (12-hour clock) as a decimal number [01,12].
  573. %p Locale's equivalent of either AM or PM.
  574. Other codes may be available on your platform. See documentation for
  575. the C library strftime function.
  576. time(...)
  577. time() -> floating point number
  578. Return the current time in seconds since the Epoch.
  579. Fractions of a second may be present if the system clock provides them.
  580. DATA
  581. altzone = -32400
  582. daylight = 0
  583. timezone = -28800
  584. tzname = ('Öйú±ê׼ʱ¼ä', 'ÖйúÏÄÁîʱ')
  585. FILE
  586. (built-in)

基本运算符

以下形符属于运算符:

+ - * ** / // % @
<< >> & | ^ ~
< > <= >= == !=

#分隔符

以下形符在语法中归类为分隔符:

( ) [ ] { }
, : . ; @ = ->
+= -= *= /= //= %= @=
&= |= ^= >>= <<= **=

句点也可出现于浮点数和虚数字面值中。连续三个句点有表示一个省略符的特殊含义。以上列表的后半部分为增强赋值操作符,在词法中作为分隔符,但也起到运算作用。

以下可打印 ASCII 字符作为其他形符的组成部分时具有特殊含义,或是对词法分析器有重要意义:

’ “ # \

以下可打印 ASCII 字符不在 Python 词法中使用。如果出现于字符串字面值和注释之外将无条件地引发错误:

$ ? `

来源:https://docs.python.org/zh-cn/3/reference/lexical_analysis.html#operators

基本语法

跟着文档一步步学就可以了 https://docs.python.org/zh-cn/3/tutorial/index.html

这不再赘述

发表评论

表情:
评论列表 (有 0 条评论,427人围观)

还没有评论,来说两句吧...

相关阅读