coon

基本语法(数组)--Linux

半腔热情 提交于 2020-01-25 08:42:02
基本语法 数组定义 majun@instance-zqtg07w6:~$ pa pa: command not found majun@instance-zqtg07w6:~$ echo $? 127 majun@instance-zqtg07w6:~$ declare -a array majun@instance-zqtg07w6:~$ echo $array majun@instance-zqtg07w6:~$ array [ 0 ] = 111 majun@instance-zqtg07w6:~$ array [ 1 ] = 333 majun@instance-zqtg07w6:~$ array [ 2 ] = "helloworld" 数组操作 数组取值 majun@instance-zqtg07w6:~$ echo $array 111 majun@instance-zqtg07w6:~$ echo $array [ 2 ] 111 [ 2 ] majun@instance-zqtg07w6:~$ echo ${array[2]} helloworld majun@instance-zqtg07w6:~$ echo ${array[1]} 333 majun@instance-zqtg07w6:~$ echo ${array[@]} 111 333

python连接mysql

故事扮演 提交于 2019-12-07 23:44:29
from __future__ import division import pymysql coon = pymysql.connect( host = '',user = 'r',passwd = 'bQ', port =,db = '',charset = '' ) f =file('ddd.txt') i = 0 p_id_dic = {} lists = [] cur = coon.cursor() for line in f: i += 1 chunk = line.strip().split('\t') p_id = chunk[0] price = round(float(chunk[2]) / 1, 2) p_id_dic[int(p_id)] = price lists.append(p_id) if i % 1000: sql = "select p_id, pay_price,total_price from map_ugc_core.task_package where p_id in (%s)" % ','.join(lists) cur.execute(sql) res = cur.fetchall() for db_pid, db_price,total_price in res: if abs(db_price - p_id_dic.get(db