[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-571785-105":53,"doc-detail-571785-en":127},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","python-notes-cheat-sheet","Python Notes - Cheat Sheet","","Python Notes and Cheat Sheet汇聚了Python语法与常用约定的速查要点，包括注释、代码块缩进规范、换行规则、命名约定、基本数据类型与示例，以及常见运算符的含义与边界提醒。内容进一步覆盖if/for/while等流程控制、三元表达式、try/except/finally异常处理框架、常见异常类型及raise用法，并列出模块导入方式与高频模块用途，便于快速定位语法与用法。",{"@graph":63,"@context":119},[64,80,102],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/python-notes-cheat-sheet/571785/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/python-notes-cheat-sheet/571785.png","ImageObject",442,249,{"name":88,"@type":89},"acoobca","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-22","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",7,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"Python 中注释和代码块的写法有什么要点？","Question",{"text":109,"@type":110},"注释从井号#开始到行末。代码块需按冒号引导并使用四个空格缩进，避免混用制表符与空格。","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"Python 的常见换行规则是什么？",{"text":114,"@type":110},"通常一条语句应保持在同一行；当涉及括号(), [], {} 时可跨行拆分。若必须连续语句可用行末反斜杠，但可能更难排查。",{"name":116,"@type":107,"acceptedAnswer":117},"如何使用 try/except/finally 处理异常？",{"text":118,"@type":110},"用try包裹可能抛错的语句，再用except(错误类型)捕获；else用于无异常时的附加逻辑；finally用于无论是否异常都执行的收尾步骤。","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},571785,1792148299,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":130,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":101,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":76},3985747870733,"https://ap-avatar.wpscdn.com/davatar_a8503ba1806abce46bf441b54a3ca4cd","Python Notes/Cheat Sheet  \nComments  \n\\# from the hash symbol to the end of a line  \nCode blocks  \nDelineated by colons and indented code; and not the curly brackets of C, C++ and Java.  \ndef is_fish_as_string(argument): if argument:  \nreturn 'fish'else:  \nreturn 'not fish'  \nNote: Four spaces per indentation level is the Python standard. Never use tabs: mixing tabs and spaces produces hard-to-find errors. Set your editor to convert tabs to spaces.  \nLine breaks  \nTypically, a statement must be on one line. Bracketed code- (), [] or {} -can be split across lines; or (if you must) use a backslash \\ at the end of a line to continue a statement on to the next line (but this can result in hard to debug code) .  \nNaming conventions  \n\n| Style | Use |\n| --- | --- |\n| StudlyCase | Class names |\n| joined_lower | Identifiers, functions; and class methods, attributes |\n| _joined_lower | Internal class attributes |\n|  joined_lower | Private class attributes\u003Cbr>\\# this use not recommended |\n| joined_lower ALL_CAPS | Constants |\n\nBasic object types (not a complete list)  \n\n| Type | Examples |\n| --- | --- |\n| None | None \\# singleton null object |\n| Boolean | True, False |\n| integer | -1, 0, 1, sys. maxint |\n| long | 1L, 9787L \\# arbitrary length ints |\n| float | 3.14159265\u003Cbr>inf, float('inf') \\# infinity\u003Cbr>-inf \\# neg infinity nan, float('nan') \\# not a number |\n| complex | 2+3j \\# note use of j |\n| string | 'I am a string', \"me too\"'''multi-line string''', \"\"\"+1\"\"\"r'raw string', b'ASCII string'u'unicode string' |\n| tuple | empty = () \\# empty tuple (1, True, 'dog') \\# immutable list |\n| list | empty = [] \\# empty list [1, True, 'dog'] \\# mutable list |\n| set | empty = set() \\# the empty set set(1, True, 'a') \\# mutable |\n| dictionary | empty = {} \\# mutable object {'a': 'dog', 7: 'seven’, True: 1} |\n| file | f = open('filename', 'rb') |\n\nNote: Python has four numeric types (integer, float, long and complex) and several sequence types including strings, lists, tuples, bytearrays, buffers, and range objects.  \nOperators  \n\n| Operator | Functionality |\n| --- | --- |\n| + | Addition (also string, tuple, list, and other sequence concatenation) |\n| - | Subtraction (also set difference) |\n| * | Multiplication (also string, tuple, list replication) |\n| / | Division |\n| % | Modulus (also a string format function, but this use deprecated) |\n| // | Integer division rounded towards minus infinity |\n| ** | Exponentiation |\n| =, -=, +=, /=,\u003Cbr>*=,%=, //=,\u003Cbr>**= | Assignment operators |\n| ==, !=, \u003C, \u003C=,>=, > | Boolean comparisons |\n| and, or, not | Boolean operators |\n| in, not in | Containment test operators |\n| is, is not | Object identity operators |\n| | , ^, &, ~ | Bitwise: or, xor, and, compliment |\n| \u003C\u003C, >> | Left and right bit shift |\n| ; | Inline statement separator\u003Cbr>\\# inline statements discouraged |\n\nHint: float('inf') always tests as larger than any number, including integers.  \nModules  \nModules open up a world of Python extensions that can be imported and used. Access to the functions, variablesand classes of a module depend on how the module was imported.  \n\n| Import method | Access/Use syntax |\n| --- | --- |\n| import math | math.cos(math.pi/3) |\n| import math as m\u003Cbr>\\# import using an alias | m.cos(m.pi/3) |\n| from math import cos, pi \\# only import specifics | cos(pi/3) |\n| from math import *\u003Cbr>\\# BADish global import | log(e) |\n\nGlobal imports make for unreadable code!!! Oft used modules  \n\n| Module | Purpose |\n| --- | --- |\n| datetime time | Date and time functions |\n| math | Core math functions and the constants pi and e |\n| pickle | Serialise objects to a file |\n| os\u003Cbr>os.path | Operating system interfaces |\n| re | A library of Perl-like regular expression operations |\n| string | Useful constants and classes |\n| sys | System parameters and functions |\n| numpy | Numerical python library |\n| pandas | R DataFrames for Python |\n| matplotlib | Plotting/charting for Python |\n\nVersion 25 April 2017- [Draft – Mark Graph – mark dot the","cbCaipQupRhdwoF3","https://ap.wps.com/l/cbCaipQupRhdwoF3","pdf",478087,"English","# Python Notes - Cheat Sheet\n## Comments and Code Blocks\n## Line Breaks\n## Naming Conventions\n## Basic Object Types\n## Operators\n## Modules and Imports\n## If/For/While Control Flow\n## Ternary Statement\n## Exceptions and Error Handling","[{\"question\":\"Python 中注释和代码块的写法有什么要点？\",\"answer\":\"注释从井号#开始到行末。代码块需按冒号引导并使用四个空格缩进，避免混用制表符与空格。\"},{\"question\":\"Python 的常见换行规则是什么？\",\"answer\":\"通常一条语句应保持在同一行；当涉及括号(), [], {} 时可跨行拆分。若必须连续语句可用行末反斜杠，但可能更难排查。\"},{\"question\":\"如何使用 try/except/finally 处理异常？\",\"answer\":\"用try包裹可能抛错的语句，再用except(错误类型)捕获；else用于无异常时的附加逻辑；finally用于无论是否异常都执行的收尾步骤。\"}]","Python Notes - Cheat Sheet | PDF",1791923723]