python learning2.py】的更多相关文章

L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack'] # 取前3个元素的笨方法 r = [] n = 3 for i in range(n): r.append(L[i]) print(r) # 切片 # 从索引0开始取,直到索引3为止,但不包括索引3.即索引0,1,2,正好是3个元素. print(L[0:3]) print(L[:3]) #如果第一个索引是0,还可以省略: print(L[-2:-1]) L = list(range(100)) p…
1.python调用py,在py中的os.getcwd()获取的不是py的路径,可以通过os.path.split(os.path.realpath(__file__))[0]来获取py的路径. 2.当py中有调用类似rar这种命令时,会出现路径问题.这个时候在py同目录下建bat批处理,然后由python调用这个bat.bat格式如下 D:CD D:\XXXcall python xxx.py…
#!/usr/bin/env python # coding=utf-8 import threading import requests import Queue import sys import re import time import warnings import datetime import argparse __author__ = 'depycode' warnings.filterwarnings("ignore") #ip to num def ip2num(i…
1. 查看帮助,我们可以在python命令行交互环境下用 help函数,比如: 查看 math 模块: >>> help('math')Help on built-in module math: NAME math DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. FUNCTIONS acos(..…
在命令行输入python manage.py createsuperuser按照提示输入即可记得先初始化表. django>1.7 python manage.py makemigrationspython manage.py migrate django<1.7python manage.py syncdb…
做python项目,需要用到mysql,一般用python-mysql,安装时遇到错误提示如下: Command "python setup.py egg_info" failed with error code 1 Trace的关键信息是:sh: mysql_config: command not found 解决方法是: 执行语句:PATH="$PATH":/usr/local/mysql/bin 再安装就好了. 原因分析:我在虚拟环境下运行的python,应该…
转自http://www.cnpythoner.com/post/2.html Python中的Module是比较重要的概念.常见的情况是,事先写好一个.py文 件,在另一个文件中需要import时,将事先写好的.py文件拷贝 到当前目录,或者是在sys.path中增加事先写好的.py文件所在的目录,然后import.这样的做法,对于少数文件是可行的,但如果程序数目很 多,层级很复杂,就很吃力了.有没有办法,像Java的Package一样,将多个.py文件组织起来,以便在外部统一调用,和在内部互…
I have installed a python package with python setup.py install How do I uninstall it? ================================================================= You need to remove all files manually, and also undo any other stuff that installation did manuall…
python 运行python manege.py runserver时报错:“no module named djangorestframework” 的解决方案 importerror:no module named djangorestframework Django REST framework is a powerful and flexible toolkit that makes it easy to build Web APIs. Some reasons you might w…
安装Web.py root@bt:~# sudo pip install web.py Downloading/unpacking web.py Downloading web.py-0.37.tar.gz (90Kb): 90Kb downloaded Running setup.py egg_info for package web.py Installing collected packages: web.py Running setup.py install for web.py Suc…