I wrote a python script, but the direct remote connection with putty to #python xxx.py execute, close the Putty script is also closed, here need to use the ' setsid ' command.#setsid python xxx.py
1
This allows the script to be added to the background for executionIf you want to see all the processes running in the background#ps -aux
1
[,... [, CB]]) Displays the contents of the path directory, the optional parameter CB is a callback function that is passed to the Retrlines () methodNlst ([path[,...]) is similar to Dir (), but returns a list of file names instead of displaying themRetrlines (cmd [, CB]) given an FTP command (such as "RETR filename") for downloading a text file. Optional callback function CB is used to process each line of the fileRetrbinary (cmd, cb[,bs=8192[, RA]) is similar to Retrlines (), except that this
model.
2. Export all data based on the road name
The actual data processing method is as follows:
1. Assign the name field added to the road GIS data to its FID, reload the network data, and generate a model.
2. Modify the Python script:
28 in the range parameter is the number of roads + 1 (currently, the circular model is exported based on the number of roads)
3. Execute the preceding script to obtain the result.
Note:
1. The sample data used
#######################################!/usr/bin/env python#encoding =utf-8From multiprocessing import Process,lockImport Time,osdef say (i):print ' Nihao: ', I#lock =lock ()For n in range (101):P=process (target=say,args= (n,))P.start ()#p. Join ()####################################### #多线程池Pool to limit the number of threads#!/usr/bin/env python#encoding =utf-8Import multiprocessingImport Os,sys,timeResu
=threading. Thread (Target=target,args=args)#加上setDaemon (True), the main thread does not wait for the child thread to close all threads, and all thread print debugging content in the subnet will not be displayed at the foreground.# T.setdaemon (True)T.start ()def put_ip (Log_name,log):Global queueWhile 1:Ip=get_guest_ip_info (log)Queue.put ([Log_name,ip])def handle ():The #为避免put_ip陷入死循环 (while 1:) cannot execute the subsequent code, so each function is run separately with one thread.#target目标函
Install glibc.i6863. After the download is complete, unzip the terminal into the root directory of the SDK and execute: Tools/android Update SDK--no-ui4. Configuring/etc/profile Environment variablesExport Android_home=/usr/local/android-sdk-linuxExport Path=${android_home}/tools:${path}:${android_home}/platform-tools: $PATH5. In Terminal input: Android, if the Android SDK Manager window comes out, it proves the environment is configured successfully6. Enter the $sdk_home/toos directory and run
backup directory:, dir2# update file list source_files=comparame (DIR1,NBSP;DIR2) foriteminsource_files:# Replace the source directory path with the backup directory path Dest_item=re.sub (Dir1, dir2,item) # If you need to synchronize a directory, create a Ifos.path.isdir (item): Os.makedirs (Dest_item) # If you need to synchronize a file , copy Ifos.path.isfile (item): Shutil.copyfile (Item,dest_item) Main ()Finally, put this script into the crontab task.This article is from a "sense of dire
For the first time, try to write a complete and useful program in Python, which implements the ability to rename the specified file in the current file in a certain order, or a certain value.Paste the following code#coding: Utf-8Import OSperfix= ' Test ' #perfix为重命名后的文件起始字符Length=2#length the length of the file name to be reached after removing Perfixbase=1# The starting number of the file nameformat= ' txt ' #文件的后缀#函数PadLeft将文件名补全到指定长度#str为将要补全的字符#nu
#!/usr/bin/env python# _*_coding:utf-8_*_import osimport sysimport statvfsdef Main (): ' Deamon ' if ' Linux ' not in Sys.platform:print ' sorry! System Opreation not supply! ' Sys.exit (3) mount = [] result = [] label = [] status = 0 with open ('/proc/mounts ') as F:for V in F: v = v.split () Mountname = v[1] If v[0] in Mount:continue mou Nt.append (V[0]) TRY:VFS=OS.STATVFS (mountname) except Oserror:print ' Mounted Device error, p
Find the Python script for the more than 1 years directory:Note:1. Datetime.timedelta represents 2 time differenceVI a1.py#!/usr/bin/pythonImport OSImport datetimeDir= "/Home"now = Datetime.datetime.now ()Delta = Datetime.timedelta (days=365)Os.chdir (dir)For Root,dirs,files in Os.walk (dir):For F in dirs:if f = = "AA":Mtime = Datetime.datetime.fromtimestamp (Os.path.getmtime (Os.path.join (root,f)))If Mtime Print Os.path.join (root,f): WqPython a1.py
1. WindowsControl Panel--"management tool--" Task Scheduler-- Create Task Next is to set the timing of execution and script path, etc.1 "GeneralSet the task name description, and whether you need to log in when executing.2 "" TriggerThe trigger specifies when to execute, whether it is performed only once or repeatedly.3 "OperationThe task to be performed by the action settings is to execute our Python script on a timed basis, where the red box is cir
Show multiple statements on the same linePython can use multiple statements in the same row, with semicolons (;) split between statements, and here's a simple example:Instance (Python 3.0+)#!/usr/bin/python3 import sys; x = 'runoob'; sys. StdOut. Write(x + '\ n') Use the script to execute the above code, and the output is:RunoobExecuted using the interactive command line, the output is:>>>import sys; =' Runoob '; sys. StdOut. Write(+' \
The following code is tested under Python 2.6.6 Add an account and change your password: (Note: Linux expect command can also be completed, interactive auto-input function) #!/usr/bin/envpythonaccount= ' sl_t1 ' passwd= ' a1p2p3l4e5 ' cmd_useradd= ' useradd %s ' % (account) #添加用户命令, modify Importsubprocessas as needed spdefuseradd ():cmd= ' exportlc_all=en_us%s ' % (cmd _useradd) F=open ('/dev/null ', ' W ') ret=sp.call (cmd,shell=true,stdout=f, NBS
Gquan_article_info where crawl_time> '" +str (Two_hours_ago) + "'")Results = Cursor.fetchall ();Count = 0For row in results:Count = Row[0]Print "Info\t Current time:" + str (currtime) + "\ t two hours before the crawl quantity is:" +str (count)if Count = = 0:Tag = Mailutil.send_mail (Mailto_list, ' You have no data in your lap news data stream for two hours ', ' you have problems with your lap news stream, please check (47 database Gquan_article_info) to fix!!!!!! ')If tag:Print "Error\t Curren
The function of this script is to uninstall all third-party apps installed in Android phone, mainly using adb shell pm, adb Uninstall command, so the premise is to use the environment variable of ADB, the following code:1 #!/usr/bin/env python2 3 ImportOS4 5 defUninstall ():6Os.popen ("adb wait-for-device")7 Print "Start Uninstall ..."8 forPackagesinchOs.popen ("adb shell pm list packages-3"). ReadLines ():9PackageName = Packages.split (":") [-1].splitlines () [0]TenOs.popen ("adb Unins
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.