Python errors All In One

SyntaxError: invalid character in identifier

\u200b, ZERO WIDTH SPACE

https://stackoverflow.com/questions/14844687/invalid-character-in-identifier

SyntaxError: invalid syntax

if__name__ == "__main__":

# if 关键字,后面加空格
if __name__ == "__main__":

用于区分,如何执行 Python 模块

https://www.jcchouinard.com/python-if-name-equals-main/

https://www.freecodecamp.org/news/if-name-main-python-example/#:~:text=We can use an if,name if it is imported.


# Python program to execute
# main directly
print ("Always executed") if __name__ == "__main__":
# 模块, 被直接执行的时候
print ("Executed when invoked directly")
else:
# 模块,被 import 使用的时候
print ("Executed when imported")

https://www.geeksforgeeks.org/what-does-the-if-name-main-do/

# Suppose this is foo.py.

print("before import")
import math print("before functionA")
def functionA():
print("Function A") print("before functionB")
def functionB():
print("Function B {}".format(math.sqrt(100))) print("before __name__ guard")
if __name__ == '__main__':
functionA()
functionB()
print("after __name__ guard")

https://stackoverflow.com/questions/419163/what-does-if-name-main-do

emoji bug

$ ls
# chmod 777 / chmod 755
$ chmod +x ./dict.py # 可执行脚本
# #!/usr/bin/python3
$ ./dict.py
# 指定解释器
$ python3 ./dict.py

#!/usr/bin/python3 # 一行 OK
# dict = {'Name': 'xgqfrms', 'Age': 18, 'Class': 'First'} # 多行错误
dict = {
'Name': 'xgqfrms',
'Age': 18,
'Class': 'First',
'Country': 'China ',
} # 更新 Age
dict['Age'] = 23 # 添加信息
dict['School'] = "Python 教程" print ("dict['Age']: ", dict['Age'])
print ("dict['School']: ", dict['School'])
print ("dict['Country']: ", dict['Country'])

https://www.runoob.com/python3/python3-dictionary.html

refs



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


Python errors All In One的更多相关文章

  1. Python Errors and Exceptions

    1. python中的try{}catch{} 2. raise exception 3. try...except ... else.. 4. finally块 python中的异常处理的keywo ...

  2. arcgis python 异常处理

    import arcpy in_features = "c:/base/transport.gdb/roads" try: # Note: CopyFeatures will al ...

  3. arcgis python 发送邮件

    import arcgisscripting, smtplib, os, sys, traceback from email.MIMEMultipart import MIMEMultipart fr ...

  4. caffe2--Install

    Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...

  5. caffe2--ubuntu16.04--14.04--install

    Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...

  6. Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean

    http://www.360doc7.net/wxarticlenew/541275971.html 一.什么是源码包软件? 顾名思义,源码包就是源代码的可见的软件包,基于Linux和BSD系统的软件 ...

  7. linux安装python3.*,更换Python2.*

    下载并解压:Python-3.5.7.tgz [root@AH-aQYWTYSJZX01 python3]# ll total 20268 -rw-r----- 1 temp01 temp01 207 ...

  8. Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean 假目标

    http://www.360doc7.net/wxarticlenew/541275971.html 一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 ...

  9. Python Tutorial 学习(八)--Errors and Exceptions

    Python Tutorial 学习(八)--Errors and Exceptions恢复 Errors and Exceptions 错误与异常 此前,我们还没有开始着眼于错误信息.不过如果你是一 ...

随机推荐

  1. 糊糊的学习笔记--Fiddle抓包

    Fiddle简述 Fiddler是一个http调试代理,它能 够记录所有的你电脑和互联网之间的http通讯,Fiddler 可以也可以让你检查所有的http通讯,设置断点,以及Fiddle 所有的&q ...

  2. WinForm中实现按Enter将光标移动到下一个文本框

    首先窗体加载出来是上面这个样子.有五个文本框,我们要实现的功能就是输入姓名后按Enter,使光标直接定位到手机号中. 在页面加载的时候我们就要获取所有文本框控件,并添加回车事件 private voi ...

  3. https://www.cnblogs.com/wclwcw/p/7515515.html

    https://www.cnblogs.com/wclwcw/p/7515515.html

  4. C++学习之STL(一)vector

    前言 C++ Primer Plus读书笔记(三)复合类型 中已经简单介绍过vector是什么,这个系列主要是介绍STL特性. 声明 vector<ElemType> c; //创建一个空 ...

  5. LOJ10100

    原题来自:CEOI 1996 一个电话线公司(简称 TLC)正在建立一个新的电话线缆网络,他们连接了若干个地点,编号分别从 1 到 N,没有两个地点有相同的号码,这些线是双向的并且能使两个地点保持通讯 ...

  6. c++ stl list使用总结(转)

    转自:http://blog.csdn.net/nupt123456789/article/details/8120397 #include <iostream> #include < ...

  7. python--可迭代对象、迭代器和生成器

    迭代器 1.什么是迭代器? 不依赖于索引的取值方式 迭代是一个重复的过程,即每一次重复为一次迭代,并且每次迭代的结果都是下一次迭代的初始值 示例: str1 = 'abcde' count = 0 w ...

  8. DEDECMS:安装百度UEDITOR编辑器

    第一步:下载相对应编辑器的版本 首先,去百度搜索"百度ueditor编辑器",然后点击进入官网,找到下载页面.找到我们想要的编辑器的版本,看自己网站的编码是UTF-8还是GBK,下 ...

  9. Flink-v1.12官方网站翻译-P005-Learn Flink: Hands-on Training

    学习Flink:实践培训 本次培训的目标和范围 本培训介绍了Apache Flink,包括足够的内容让你开始编写可扩展的流式ETL,分析和事件驱动的应用程序,同时省略了很多(最终重要的)细节.本书的重 ...

  10. k8s 调度 GPU

    最近公司有项目想在 k8s 集群中运行 GPU 任务,于是研究了一下.下面是部署的步骤. 1. 首先得有一个可以运行的 k8s 集群. 集群部署参考 kubeadm安装k8s 2. 准备 GPU 节点 ...