[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-573835-105":3,"detail-sidebar-cat-1-en-105":79,"doc-detail-573835-en":125},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":72,"head_meta":74,"extra_data":76,"updated_unix":78},105,"en","python-livecode-cheat-sheet","Python-Livecode Cheat Sheet","","Python-Livecode Cheat Sheet汇总了脚本编写的核心语法与常用操作要点。内容涵盖注释、变量与字符串处理、正则匹配示例、可自定义的自定义处理器（handlers）、常见控制结构（for/while/if/switch等）、排序技巧、布尔与字符串运算、切片与分割等分块操作，以及文件与进程读写流程。还提供基于对话框的用户输入与通知用法示例，便于快速对照参考。",{"@graph":14,"@context":71},[15,34,54],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/presentations/","Presentations",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/python-livecode-cheat-sheet/573835/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":48,"encodingFormat":47,"isAccessibleForFree":49,"interactionStatistic":50},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/python-livecode-cheat-sheet/573835.png","ImageObject",442,249,{"name":42,"@type":43},"Mimi","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-14",true,{"@type":51,"interactionType":52,"userInteractionCount":22},"InteractionCounter",{"@type":53},"ViewAction",{"@type":55,"mainEntity":56},"FAQPage",[57,63,67],{"name":58,"@type":59,"acceptedAnswer":60},"该速查表包含哪些基础语法板块？","Question",{"text":61,"@type":62},"包含注释、变量、字符串处理、正则（Regex）、自定义处理器、控制结构、排序、运算符、文件与进程、数组处理以及用户输入/通知等板块。","Answer",{"name":64,"@type":59,"acceptedAnswer":65},"变量在该速查表中如何使用？",{"text":66,"@type":62},"变量用于存储信息，并可在需要时访问或修改。文中给出了字符串赋值、数字赋值、字典式键值存取，以及类似本地变量与“put into”写入的写法示例。",{"name":68,"@type":59,"acceptedAnswer":69},"它对字符串与正则的处理提供了什么示例？",{"text":70,"@type":62},"字符串处理包含拼接、切片/分块、split/join、startswith/endswith 等示例；正则部分展示了 match 与 group 的用法，并给出用正则过滤行与从匹配结果中提取值的用法。","https://schema.org",{"og:url":32,"og:type":73,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":75,"canonical":32},"index,follow",{"doc_id":77,"site_id":7},573835,1792014483,{"code":4,"msg":80,"data":81},"success",[82,86,91,96,101,106,111,116,121],{"id":83,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":84,"slug":85},11,90,"presentations",{"id":87,"doc_module":22,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},12,"Resumes",80,"resumes",{"id":92,"doc_module":22,"doc_module_name":25,"category_name":93,"show_sort_weight":94,"slug":95},14,"Invoices",70,"invoices",{"id":97,"doc_module":22,"doc_module_name":25,"category_name":98,"show_sort_weight":99,"slug":100},15,"Posters",60,"posters",{"id":102,"doc_module":22,"doc_module_name":25,"category_name":103,"show_sort_weight":104,"slug":105},16,"Social Media",50,"social-media",{"id":107,"doc_module":22,"doc_module_name":25,"category_name":108,"show_sort_weight":109,"slug":110},17,"Forms",40,"forms",{"id":112,"doc_module":22,"doc_module_name":25,"category_name":113,"show_sort_weight":114,"slug":115},18,"Letters",30,"letters",{"id":117,"doc_module":22,"doc_module_name":25,"category_name":118,"show_sort_weight":119,"slug":120},21,"Paper Templates",5,"papers-templates",{"id":122,"doc_module":22,"doc_module_name":25,"category_name":123,"show_sort_weight":4,"slug":124},158,"General","general-158",{"code":4,"msg":80,"data":126},{"doc_id":77,"user_id":127,"nickname":42,"user_avatar":128,"doc_module":22,"category_id":83,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":129,"file_id":130,"file_url":131,"file_type":132,"file_size":133,"view_count":22,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":33,"language":134,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":135,"faqs":136,"seo_title":137,"seo_description":12,"update_tm":138,"read_time":26},2336477974920,"https://ap-avatar.wpscdn.com/davatar_155a257f0dc6eb9ab79c44ca47cae57d","Python-Livecode Cheat Sheet  \nComments  \nComments allow you to add explanations and annotations to your code.  \n\\# this is commented out --these  \n\\# are // all  \n/* commented  \nout */  \nVariables  \nVariables are used to to store information, the stored value can be changed or accessed when you need it.  \nvar = \"str\"  \nvar = 1  \nvar[\"key\"] = \"val\"  \nlocal tVar  \nput \"str\" into tVar  \nput 1 into tVar  \nput \"val\" into tVar[\"key\"]  \nString Processing  \nThese examples show how string values can be manipulated.  \n\\# General  \nvar = 'a' + var  \nvar = var[1:]  \nvar. replace(\"_ \", \" -\")  \n\\# Regex  \nfound = re. match('([0-9])', '1') [num = tMatch.group](num = tMatch.group)(1)  \nfor line in var:  \nif re. match(pattern, line): filtered.push(line) var = '\\n'.join(filtered)  \n// General  \nput \"a\" before tVar delete char 1 of tVar replace \"_ \" with \" - \" in tVar  \n// Regex  \nmatchText(\"1\", \"([0-9])\", tN) is true tN is 1  \nfilter lines of tVar with regex pattern tPattern  \nCustom Handlers  \nA custom handler is a function or command that you define yourself.  \ndef foo(param):  \n\\# return something  \n\\# foo(var)  \nfunction foo pParamend foo  \n// get foo(tVar)  \ncommand bar pParamend bar  \nControl Structures  \nControl structures are used to control what code is executed and how many times.  \nfor x in tVar:  \n\\# do things  \nfor x in range(5):  \n\\# do things  \nwhile x \u003C 10: x- = 1  \nif tVar:  \nelif tOther:  \nelse:  \nrepeat for each char tChar in tVarend repeat  \nrepeat 10  \nend repeat  \nrepeat with x = 1 to 10  \nend repeat  \nrepeat while x \u003C 10 subtract 1 from x  \nend repeat  \nif true then   else    \nif tVar then  \nelse if tOther then else  \nend if  \nswitch tVar case \"a\"  \nbreak  \ndefault  \nbreak  \nend switch  \nSorting  \nThese examples show how to sort items and lists.  \nlist = [5, 2, 3, 1, 4]  \nsorted(list) == [1, 2, 3, 4, 5]  \nsorted(list, reverse=True) == [5, 4, 3, 2, 1]  \ndata = [(6, 1), (8, 3), (2, 2)]  \nsorted(data, key=itemgetter(2)) == [(6, 1),(2, 2), (8, 3)]  \nlocal tList  \nput \"5,2,3,1,4\" into tList  \nsort items of tList ascending numeric-> tList is \"1,2,3,4,5\"  \nsort items of tList descending numeric-> tList is \"5,4,3,2,1\"  \nlocal tData put \"6,1 : 8,3 : 2,2\" into tData set the lineDelimiter to \":\"  \nsort lines of tData ascending numeric by item 2 of each  \n-> tData is \"6,1 : 2,2 : 8,3\"  \nOperators  \nOperators are ways of combining values such as boolean values, numbers or strings, to produce other values.  \n\\# Logical  \ntrue and false == false true or false == true!false == true  \n\\# String  \n\"foo\" + \"bar\" == \"foobar\"strs = ['foo','bar']' '.join(strs) == \"foo bar\"\"str\".startswith(\"st\")  \n\"str\".endswith(\"g\")  \n\\# Chunks  \n\"str\"[4 : 5] == \"n\"  \nitems = \"a, b,c\".split(\",\") items[2] == \"c\"  \nwords = \"hi there\".split(\" \") words[0] == \"hi\"  \nlines = \"a\\nb\".split(\"\\n\") lines[2] == \"b\"  \nlines = \"a, b,c\".split(\"\\n\") items = lines[1] .split(\",\") items[1][0 :1] == \"a\"  \n// Logical  \ntrue and false is false true or false is true not false is true  \n// String  \n\"foo\" & \"bar\" is \"foobar\"  \n\"foo\" && \"bar\" is \"foo bar\"  \n\"str\" begins with \"st\"  \n\"str\" ends with \"g\"  \n// Chunks  \nchar 5 of \"str\" is \"n\"  \nitem 3 of \"a, b,c\" is \"c\"  \nword 1 of \"hi there\" is \"hi\"  \nline 2 of \"a\" & return & \"b\" is \"b\"  \n// Compound chunks  \nchar 1 of item 1 of line 1 of \"a, b,c\" is \"a\"  \nFiles & Processes  \nThese examples show how to read from and write to files and processes.  \nopen(tPath).read()  \nopen(tPath).write(\"\")  \nprocess = subprocess. Popen([tProc], stdout=subprocess.PIPE)  \nwhile True: process.wait()  \n[data = process.stdout.read](data = process.stdout.read)(5)  \nif data: break  \nget url ( \"file:/\" & tPath)  \nput \"\" into url (\"file:/\" & tPath)  \nopen process tProc  \nread from process tProc for 5 close process tProc  \nArray Processing  \nThese examples show how array values can be manipulated.  \n\\# Split / combine  \nvar = \"a, b,c\".split(\",\")  \nvar[1] is \"b\"','.join(var) var == \"a, b,c\"  \n\\# Iteration for key in array:  \n\\# do something with array[key]  \n\\# Lengt","cbCaijlL47xrdwkt","https://ap.wps.com/l/cbCaijlL47xrdwkt","pdf",39482,"English","# Comments\n# Variables\n# String Processing\n# Regex\n# Custom Handlers\n# Control Structures\n# Sorting\n# Operators\n# Files & Processes\n# Array Processing\n# User Input / Notification","[{\"question\":\"该速查表包含哪些基础语法板块？\",\"answer\":\"包含注释、变量、字符串处理、正则（Regex）、自定义处理器、控制结构、排序、运算符、文件与进程、数组处理以及用户输入/通知等板块。\"},{\"question\":\"变量在该速查表中如何使用？\",\"answer\":\"变量用于存储信息，并可在需要时访问或修改。文中给出了字符串赋值、数字赋值、字典式键值存取，以及类似本地变量与“put into”写入的写法示例。\"},{\"question\":\"它对字符串与正则的处理提供了什么示例？\",\"answer\":\"字符串处理包含拼接、切片/分块、split/join、startswith/endswith 等示例；正则部分展示了 match 与 group 的用法，并给出用正则过滤行与从匹配结果中提取值的用法。\"}]","Python-Livecode Cheat Sheet | PDF",1791948128]