锘??xml version="1.0" encoding="utf-8" standalone="yes"?>湖南赛车电视走势图:BlogJava - ▼幸运赛车规则▼幸运赛车投注▼幸运赛车开奖结果查询▼湖南幸运赛车开奖奖金▼幸运赛车走势▼//www.cqk4s.cn/xzclog/zh-cnSun, 24 Mar 2019 20:15:55 GMTSun, 24 Mar 2019 20:15:55 GMT60Python璇诲啓銆佸垱寤烘枃浠?/title><link>//www.cqk4s.cn/xzclog/archive/2018/11/28/433526.html</link><dc:creator>xzc</dc:creator><author>xzc</author><pubDate>Wed, 28 Nov 2018 03:52:00 GMT</pubDate><guid>//www.cqk4s.cn/xzclog/archive/2018/11/28/433526.html</guid><wfw:comment>//www.cqk4s.cn/xzclog/comments/433526.html</wfw:comment><comments>//www.cqk4s.cn/xzclog/archive/2018/11/28/433526.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.cqk4s.cn/xzclog/comments/commentRss/433526.html</wfw:commentRss><trackback:ping>//www.cqk4s.cn/xzclog/services/trackbacks/433526.html</trackback:ping><description><![CDATA[ 鍘熸枃閾炬帴锛//www.cnblogs.com/juandx/p/4962089.html python涓鏂囦欢銆佹枃浠跺す锛堟枃浠舵搷浣滃嚱鏁帮級鐨勬搷浣滈渶瑕佹秹鍙婂埌os妯″潡鍜宻hutil妯″潡銆? 寰楀埌褰撳墠宸ヤ綔鐩綍锛屽嵆褰撳墠Python鑴氭湰宸ヤ綔鐨勭洰褰曡矾寰? os.getcwd() 杩斿洖鎸囧畾鐩綍涓嬬殑鎵鏈夋枃浠跺拰鐩綍鍚?os.listdir() 鍑芥暟鐢ㄦ潵鍒犻櫎涓涓枃浠?os.remove() 鍒犻櫎澶氫釜鐩綍锛歰s.removedirs锛坮“c锛歕python”锛? 妫楠岀粰鍑虹殑璺緞鏄惁鏄竴涓枃浠讹細os.path.isfile() 妫楠岀粰鍑虹殑璺緞鏄惁鏄竴涓洰褰曪細os.path.isdir() 鍒ゆ柇鏄惁鏄粷瀵硅矾寰勶細os.path.isabs() 妫楠岀粰鍑虹殑璺緞鏄惁鐪熷湴瀛?os.path.exists() 杩斿洖涓涓矾寰勭殑鐩綍鍚嶅拰鏂囦欢鍚?os.path.split() eg os.path.split(‘/home/swaroop/byte/code/poem.txt’) 缁撴灉锛?‘/home/swaroop/byte/code’, ‘poem.txt’) 鍒嗙鎵╁睍鍚嶏細os.path.splitext() 鑾峰彇璺緞鍚嶏細os.path.dirname() 鑾峰彇鏂囦欢鍚嶏細os.path.basename() 杩愯shell鍛戒护: os.system() 璇诲彇鍜岃缃幆澧冨彉閲?os.getenv() 涓巓s.putenv() 缁欏嚭褰撳墠骞冲彴浣跨敤鐨勮缁堟绗?os.linesep Windows浣跨敤’\r\n’锛孡inux浣跨敤’\n’鑰孧ac浣跨敤’\r’ 鎸囩ず浣犳鍦ㄤ娇鐢ㄧ殑骞冲彴锛歰s.name 瀵逛簬Windows锛屽畠鏄?#8217;nt’锛岃屽浜嶭inux/Unix鐢ㄦ埛锛屽畠鏄?#8217;posix’ 閲嶅懡鍚嶏細os.rename锛坥ld锛?new锛? 鍒涘缓澶氱骇鐩綍锛歰s.makedirs锛坮“c锛歕python\test”锛? 鍒涘缓鍗曚釜鐩綍锛歰s.mkdir锛?#8220;test”锛? 鑾峰彇鏂囦欢灞炴э細os.stat锛坒ile锛? 淇敼鏂囦欢鏉冮檺涓庢椂闂存埑锛歰s.chmod锛坒ile锛? 缁堟褰撳墠杩涚▼锛歰s.exit锛堬級 鑾峰彇鏂囦欢澶у皬锛歰s.path.getsize锛坒ilename锛? 鏂囦欢鎿嶄綔锛? os.mknod(“test.txt”) 鍒涘缓绌烘枃浠? fp = open(“test.txt”,w) 鐩存帴鎵撳紑涓涓枃浠讹紝濡傛灉鏂囦欢涓嶅瓨鍦ㄥ垯鍒涘缓鏂囦欢 鍏充簬open 妯″紡锛? w 浠ュ啓鏂瑰紡鎵撳紑锛? a 浠ヨ拷鍔犳ā寮忔墦寮 (浠?EOF 寮濮? 蹇呰鏃跺垱寤烘柊鏂囦欢) r+ 浠ヨ鍐欐ā寮忔墦寮 w+ 浠ヨ鍐欐ā寮忔墦寮 (鍙傝 w ) a+ 浠ヨ鍐欐ā寮忔墦寮 (鍙傝 a ) rb 浠ヤ簩杩涘埗璇绘ā寮忔墦寮 wb 浠ヤ簩杩涘埗鍐欐ā寮忔墦寮 (鍙傝 w ) ab 浠ヤ簩杩涘埗杩藉姞妯″紡鎵撳紑 (鍙傝 a ) rb+ 浠ヤ簩杩涘埗璇诲啓妯″紡鎵撳紑 (鍙傝 r+ ) wb+ 浠ヤ簩杩涘埗璇诲啓妯″紡鎵撳紑 (鍙傝 w+ ) ab+ 浠ヤ簩杩涘埗璇诲啓妯″紡鎵撳紑 (鍙傝 a+ ) fp.read([size]) #size涓鸿鍙栫殑闀垮害锛屼互byte涓哄崟浣? fp.readline([size]) #璇讳竴琛岋紝濡傛灉瀹氫箟浜唖ize锛屾湁鍙兘杩斿洖鐨勫彧鏄竴琛岀殑涓閮ㄥ垎 fp.readlines([size]) #鎶婃枃浠舵瘡涓琛屼綔涓轰竴涓猯ist鐨勪竴涓垚鍛橈紝骞惰繑鍥炶繖涓猯ist銆傚叾瀹炲畠鐨勫唴閮ㄦ槸閫氳繃寰幆璋冪敤readline()鏉ュ疄鐜扮殑銆傚鏋滄彁渚泂ize鍙傛暟锛宻ize鏄〃绀鸿鍙栧唴瀹圭殑鎬婚暱锛屼篃灏辨槸璇村彲鑳藉彧璇诲埌鏂囦欢鐨勪竴閮ㄥ垎銆? fp.write(str) #鎶妔tr鍐欏埌鏂囦欢涓紝write()骞朵笉浼氬湪str鍚庡姞涓婁竴涓崲琛岀 fp.writelines(seq) #鎶妔eq鐨勫唴瀹瑰叏閮ㄥ啓鍒版枃浠朵腑(澶氳涓娆℃у啓鍏?銆傝繖涓嚱鏁颁篃鍙槸蹇犲疄鍦板啓鍏ワ紝涓嶄細鍦ㄦ瘡琛屽悗闈㈠姞涓婁换浣曚笢瑗裤? fp.close() #鍏抽棴鏂囦欢銆俻ython浼氬湪涓涓枃浠朵笉鐢ㄥ悗鑷姩鍏抽棴鏂囦欢锛屼笉杩囪繖涓鍔熻兘娌℃湁淇濊瘉锛屾渶濂借繕鏄吇鎴愯嚜宸卞叧闂殑涔犳儻銆?濡傛灉涓涓枃浠跺湪鍏抽棴鍚庤繕瀵瑰叾杩涜鎿嶄綔浼氫骇鐢烿alueError fp.flush() #鎶婄紦鍐插尯鐨勫唴瀹瑰啓鍏ョ‖鐩? fp.fileno() #杩斿洖涓涓暱鏁村瀷鐨?#8221;鏂囦欢鏍囩“ fp.isatty() #鏂囦欢鏄惁鏄竴涓粓绔澶囨枃浠讹紙unix绯荤粺涓殑锛? fp.tell() #杩斿洖鏂囦欢鎿嶄綔鏍囪鐨勫綋鍓嶄綅缃紝浠ユ枃浠剁殑寮澶翠负鍘熺偣 fp.next() #杩斿洖涓嬩竴琛岋紝骞跺皢鏂囦欢鎿嶄綔鏍囪浣嶇Щ鍒颁笅涓琛屻傛妸涓涓猣ile鐢ㄤ簬for … in file杩欐牱鐨勮鍙ユ椂锛屽氨鏄皟鐢╪ext()鍑芥暟鏉ュ疄鐜伴亶鍘嗙殑銆? fp.seek(offset[,whence]) #灏嗘枃浠舵墦鎿嶄綔鏍囪绉诲埌offset鐨勪綅缃傝繖涓猳ffset涓鑸槸鐩稿浜庢枃浠剁殑寮澶存潵璁$畻鐨勶紝涓鑸负姝f暟銆備絾濡傛灉鎻愪緵浜唚hence鍙傛暟灏变笉涓瀹氫簡锛寃hence鍙互涓?琛ㄧず浠庡ご寮濮嬭绠楋紝1琛ㄧず浠ュ綋鍓嶄綅缃负鍘熺偣璁$畻銆?琛ㄧず浠ユ枃浠舵湯灏句负鍘熺偣杩涜璁$畻銆傞渶瑕佹敞鎰忥紝濡傛灉鏂囦欢浠鎴朼+鐨勬ā寮忔墦寮锛屾瘡娆¤繘琛屽啓鎿嶄綔鏃讹紝鏂囦欢鎿嶄綔鏍囪浼氳嚜鍔ㄨ繑鍥炲埌鏂囦欢鏈熬銆? fp.truncate([size]) #鎶婃枃浠惰鎴愯瀹氱殑澶у皬锛岄粯璁ょ殑鏄鍒板綋鍓嶆枃浠舵搷浣滄爣璁扮殑浣嶇疆銆傚鏋渟ize姣旀枃浠剁殑澶у皬杩樿澶э紝渚濇嵁绯荤粺鐨勪笉鍚屽彲鑳芥槸涓嶆敼鍙樻枃浠讹紝涔熷彲鑳芥槸鐢?鎶婃枃浠惰ˉ鍒扮浉搴旂殑澶у皬锛屼篃鍙兘鏄互涓浜涢殢鏈虹殑鍐呭鍔犱笂鍘汇? 鐩綍鎿嶄綔锛? os.mkdir(“file”) 鍒涘缓鐩綍 澶嶅埗鏂囦欢锛? shutil.copyfile(“oldfile”,”newfile”) oldfile鍜宯ewfile閮藉彧鑳芥槸鏂囦欢 shutil.copy(“oldfile”,”newfile”) oldfile鍙兘鏄枃浠跺す锛宯ewfile鍙互鏄枃浠讹紝涔熷彲浠ユ槸鐩爣鐩綍 澶嶅埗鏂囦欢澶癸細 shutil.copytree(“olddir”,”newdir”) olddir鍜宯ewdir閮藉彧鑳芥槸鐩綍锛屼笖newdir蹇呴』涓嶅瓨鍦? 閲嶅懡鍚嶆枃浠讹紙鐩綍锛? os.rename(“oldname”,”newname”) 鏂囦欢鎴栫洰褰曢兘鏄娇鐢ㄨ繖鏉″懡浠? 绉诲姩鏂囦欢锛堢洰褰曪級 shutil.move(“oldpos”,”newpos”) 鍒犻櫎鏂囦欢 os.remove(“file”) 鍒犻櫎鐩綍 os.rmdir(“dir”)鍙兘鍒犻櫎绌虹洰褰? shutil.rmtree(“dir”) 绌虹洰褰曘佹湁鍐呭鐨勭洰褰曢兘鍙互鍒? 杞崲鐩綍 os.chdir(“path”) 鎹㈣矾寰? Python璇诲啓鏂囦欢 1.open 浣跨敤open鎵撳紑鏂囦欢鍚庝竴瀹氳璁板緱璋冪敤鏂囦欢瀵硅薄鐨刢lose()鏂规硶銆傛瘮濡傚彲浠ョ敤try/finally璇彞鏉ョ‘淇濇渶鍚庤兘鍏抽棴鏂囦欢銆? file_object = open(‘thefile.txt’) try: all_the_text = file_object.read( ) finally: file_object.close( ) 娉細涓嶈兘鎶妎pen璇彞鏀惧湪try鍧楅噷锛屽洜涓哄綋鎵撳紑鏂囦欢鍑虹幇寮傚父鏃讹紝鏂囦欢瀵硅薄file_object鏃犳硶鎵цclose()鏂规硶銆? 2.璇绘枃浠? 璇绘枃鏈枃浠? input = open('data', 'r') #绗簩涓弬鏁伴粯璁や负r input = open('data') 1 2 3 璇讳簩杩涘埗鏂囦欢 input = open('data', 'rb') 1 璇诲彇鎵鏈夊唴瀹? file_object = open('thefile.txt') try: all_the_text = file_object.read( ) finally: file_object.close( ) 1 2 3 4 5 璇诲浐瀹氬瓧鑺? file_object = open('abinfile', 'rb') try: while True: chunk = file_object.read(100) if not chunk: break do_something_with(chunk) finally: file_object.close( ) 1 2 3 4 5 6 7 8 9 璇绘瘡琛? list_of_all_the_lines = file_object.readlines( ) 1 濡傛灉鏂囦欢鏄枃鏈枃浠讹紝杩樺彲浠ョ洿鎺ラ亶鍘嗘枃浠跺璞¤幏鍙栨瘡琛岋細 for line in file_object: process line 1 2 3.鍐欐枃浠? 鍐欐枃鏈枃浠? output = open('data', 'w') 1 鍐欎簩杩涘埗鏂囦欢 output = open('data', 'wb') 1 杩藉姞鍐欐枃浠? output = open('data', 'w+') 1 鍐欐暟鎹? file_object = open('thefile.txt', 'w') file_object.write(all_the_text) file_object.close( ) 1 2 3 鍐欏叆澶氳 file_object.writelines(list_of_text_strings) 1 娉ㄦ剰锛岃皟鐢╳ritelines鍐欏叆澶氳鍦ㄦц兘涓婁細姣斾娇鐢╳rite涓娆℃у啓鍏ヨ楂樸? 鍦ㄥ鐞嗘棩蹇楁枃浠剁殑鏃跺欙紝甯稿父浼氶亣鍒拌繖鏍风殑鎯呭喌锛氭棩蹇楁枃浠跺法澶э紝涓嶅彲鑳戒竴娆℃ф妸鏁翠釜鏂囦欢璇诲叆鍒板唴瀛樹腑杩涜澶勭悊锛屼緥濡傞渶瑕佸湪涓鍙扮墿鐞嗗唴瀛樹负 2GB 鐨勬満鍣ㄤ笂澶勭悊涓涓?2GB 鐨勬棩蹇楁枃浠讹紝鎴戜滑鍙兘甯屾湜姣忔鍙鐞嗗叾涓?200MB 鐨勫唴瀹广? 鍦?Python 涓紝鍐呯疆鐨?File 瀵硅薄鐩存帴鎻愪緵浜嗕竴涓?readlines(sizehint) 鍑芥暟鏉ュ畬鎴愯繖鏍风殑浜嬫儏銆備互涓嬮潰鐨勪唬鐮佷负渚嬶細 file = open('test.log', 'r')sizehint = 209715200 # 200Mposition = 0lines = file.readlines(sizehint)while not file.tell() - position < 0: position = file.tell() lines = file.readlines(sizehint) 1 姣忔璋冪敤 readlines(sizehint) 鍑芥暟锛屼細杩斿洖澶х害 200MB 鐨勬暟鎹紝鑰屼笖鎵杩斿洖鐨勫繀鐒堕兘鏄畬鏁寸殑琛屾暟鎹紝澶у鏁版儏鍐典笅锛岃繑鍥炵殑鏁版嵁鐨勫瓧鑺傛暟浼氱◢寰瘮 sizehint 鎸囧畾鐨勫煎ぇ涓鐐癸紙闄ゆ渶鍚庝竴娆¤皟鐢?readlines(sizehint) 鍑芥暟鐨勬椂鍊欙級銆傞氬父鎯呭喌涓嬶紝Python 浼氳嚜鍔ㄥ皢鐢ㄦ埛鎸囧畾鐨?sizehint 鐨勫艰皟鏁存垚鍐呴儴缂撳瓨澶у皬鐨勬暣鏁板嶃? file鍦╬ython鏄竴涓壒娈婄殑绫诲瀷锛屽畠鐢ㄤ簬鍦╬ython绋嬪簭涓澶栭儴鐨勬枃浠惰繘琛屾搷浣溿傚湪python涓竴鍒囬兘鏄璞★紝file涔熶笉渚嬪锛宖ile鏈塮ile鐨勬柟娉曞拰灞炴с備笅闈㈠厛鏉ョ湅濡備綍鍒涘缓涓涓猣ile瀵硅薄锛? file(name[, mode[, buffering]]) 1 file()鍑芥暟鐢ㄤ簬鍒涘缓涓涓猣ile瀵硅薄锛屽畠鏈変竴涓埆鍚嶅彨open()锛屽彲鑳芥洿褰㈣薄涓浜涳紝瀹冧滑鏄唴缃嚱鏁般傛潵鐪嬬湅瀹冪殑鍙傛暟銆傚畠鍙傛暟閮芥槸浠ュ瓧绗︿覆鐨勫舰寮忎紶閫掔殑銆俷ame鏄枃浠剁殑鍚嶅瓧銆? mode鏄墦寮鐨勬ā寮忥紝鍙夌殑鍊间负r w a U锛屽垎鍒唬琛ㄨ锛堥粯璁わ級 鍐?娣诲姞鏀寔鍚勭鎹㈣绗︾殑妯″紡銆傜敤w鎴朼妯″紡鎵撳紑鏂囦欢鐨勮瘽锛屽鏋滄枃浠朵笉瀛樺湪锛岄偅涔堝氨鑷姩鍒涘缓銆傛澶栵紝鐢╳妯″紡鎵撳紑涓涓凡缁忓瓨鍦ㄧ殑鏂囦欢鏃讹紝鍘熸湁鏂囦欢鐨勫唴瀹逛細琚竻绌猴紝鍥犱负涓寮濮嬫枃浠剁殑鎿嶄綔鐨勬爣璁版槸鍦ㄦ枃浠剁殑寮澶寸殑锛岃繖鏃跺欒繘琛屽啓鎿嶄綔锛屾棤鐤戜細鎶婂師鏈夌殑鍐呭缁欐姽鎺夈傜敱浜庡巻鍙茬殑鍘熷洜锛屾崲琛岀鍦ㄤ笉鍚岀殑绯荤粺涓湁涓嶅悓妯″紡锛屾瘮濡傚湪 unix涓槸涓涓猏n锛岃屽湪windows涓槸‘\r\n’锛岀敤U妯″紡鎵撳紑鏂囦欢锛屽氨鏄敮鎸佹墍鏈夌殑鎹㈣妯″紡锛屼篃灏辫‘\r’ ‘\n’ ‘\r\n’閮藉彲琛ㄧず鎹㈣锛屼細鏈変竴涓猼uple鐢ㄦ潵瀛樿串杩欎釜鏂囦欢涓敤鍒拌繃鐨勬崲琛岀銆備笉杩囷紝铏借鎹㈣鏈夊绉嶆ā寮忥紝璇诲埌python涓粺涓鐢╘n浠f浛銆傚湪妯″紡瀛楃鐨勫悗闈紝杩樺彲浠ュ姞涓? b t杩欎袱绉嶆爣璇嗭紝鍒嗗埆琛ㄧず鍙互瀵规枃浠跺悓鏃惰繘琛岃鍐欐搷浣滃拰鐢ㄤ簩杩涘埗妯″紡銆佹枃鏈ā寮忥紙榛樿锛夋墦寮鏂囦欢銆? buffering濡傛灉涓?琛ㄧず涓嶈繘琛岀紦鍐?濡傛灉涓?琛ㄧず杩涜“琛岀紦鍐?#8220;;濡傛灉鏄竴涓ぇ浜?鐨勬暟琛ㄧず缂撳啿鍖虹殑澶у皬锛屽簲璇ユ槸浠ュ瓧鑺備负鍗曚綅鐨勩? file瀵硅薄鏈夎嚜宸辩殑灞炴у拰鏂规硶銆傚厛鏉ョ湅鐪媐ile鐨勫睘鎬с? closed #鏍囪鏂囦欢鏄惁宸茬粡鍏抽棴锛岀敱close()鏀瑰啓 encoding #鏂囦欢缂栫爜 mode #鎵撳紑妯″紡 name #鏂囦欢鍚? newlines #鏂囦欢涓敤鍒扮殑鎹㈣妯″紡锛屾槸涓涓猼uple softspace #boolean鍨嬶紝涓鑸负0锛屾嵁璇寸敤浜巔rint 1 2 3 4 5 6 file鐨勮鍐欐柟娉曪細 F.read([size]) #size涓鸿鍙栫殑闀垮害锛屼互byte涓哄崟浣? F.readline([size]) #璇讳竴琛岋紝濡傛灉瀹氫箟浜唖ize锛屾湁鍙兘杩斿洖鐨勫彧鏄竴琛岀殑涓閮ㄥ垎 F.readlines([size]) #鎶婃枃浠舵瘡涓琛屼綔涓轰竴涓猯ist鐨勪竴涓垚鍛橈紝骞惰繑鍥炶繖涓猯ist銆傚叾瀹炲畠鐨勫唴閮ㄦ槸閫氳繃寰幆璋冪敤readline()鏉ュ疄鐜扮殑銆傚鏋滄彁渚泂ize鍙傛暟锛宻ize鏄〃绀鸿鍙栧唴瀹圭殑鎬婚暱锛屼篃灏辨槸璇村彲鑳藉彧璇诲埌鏂囦欢鐨勪竴閮ㄥ垎銆? F.write(str) #鎶妔tr鍐欏埌鏂囦欢涓紝write()骞朵笉浼氬湪str鍚庡姞涓婁竴涓崲琛岀 F.writelines(seq) #鎶妔eq鐨勫唴瀹瑰叏閮ㄥ啓鍒版枃浠朵腑銆傝繖涓嚱鏁颁篃鍙槸蹇犲疄鍦板啓鍏ワ紝涓嶄細鍦ㄦ瘡琛屽悗闈㈠姞涓婁换浣曚笢瑗裤? file鐨勫叾浠栨柟娉曪細 F.close() #鍏抽棴鏂囦欢銆俻ython浼氬湪涓涓枃浠朵笉鐢ㄥ悗鑷姩鍏抽棴鏂囦欢锛屼笉杩囪繖涓鍔熻兘娌℃湁淇濊瘉锛屾渶濂借繕鏄吇鎴愯嚜宸卞叧闂殑涔犳儻銆傚鏋滀竴涓枃浠跺湪鍏抽棴鍚庤繕瀵瑰叾杩涜鎿嶄綔浼氫骇鐢烿alueError F.flush() #鎶婄紦鍐插尯鐨勫唴瀹瑰啓鍏ョ‖鐩? F.fileno() #杩斿洖涓涓暱鏁村瀷鐨?#8221;鏂囦欢鏍囩“ F.isatty() #鏂囦欢鏄惁鏄竴涓粓绔澶囨枃浠讹紙unix绯荤粺涓殑锛? F.tell() #杩斿洖鏂囦欢鎿嶄綔鏍囪鐨勫綋鍓嶄綅缃紝浠ユ枃浠剁殑寮澶翠负鍘熺偣 F.next() #杩斿洖涓嬩竴琛岋紝骞跺皢鏂囦欢鎿嶄綔鏍囪浣嶇Щ鍒颁笅涓琛屻傛妸涓涓猣ile鐢ㄤ簬for ... in file杩欐牱鐨勮鍙ユ椂锛屽氨鏄皟鐢╪ext()鍑芥暟鏉ュ疄鐜伴亶鍘嗙殑銆? F.seek(offset[,whence]) #灏嗘枃浠舵墦鎿嶄綔鏍囪绉诲埌offset鐨勪綅缃傝繖涓猳ffset涓鑸槸鐩稿浜庢枃浠剁殑寮澶存潵璁$畻鐨勶紝涓鑸负姝f暟銆備絾濡傛灉鎻愪緵浜唚hence鍙傛暟灏变笉涓瀹氫簡锛寃hence鍙互涓?琛ㄧず浠庡ご寮濮嬭绠楋紝1琛ㄧず浠ュ綋鍓嶄綅缃负鍘熺偣璁$畻銆?琛ㄧず浠ユ枃浠舵湯灏句负鍘熺偣杩涜璁$畻銆傞渶瑕佹敞鎰忥紝濡傛灉鏂囦欢浠鎴朼+鐨勬ā寮忔墦寮锛屾瘡娆¤繘琛屽啓鎿嶄綔鏃讹紝鏂囦欢鎿嶄綔鏍囪浼氳嚜鍔ㄨ繑鍥炲埌鏂囦欢鏈熬銆? F.truncate([size]) #鎶婃枃浠惰鎴愯瀹氱殑澶у皬锛岄粯璁ょ殑鏄鍒板綋鍓嶆枃浠舵搷浣滄爣璁扮殑浣嶇疆銆傚鏋渟ize姣旀枃浠剁殑澶у皬杩樿澶э紝渚濇嵁绯荤粺鐨勪笉鍚屽彲鑳芥槸涓嶆敼鍙樻枃浠讹紝涔熷彲鑳芥槸鐢?鎶婃枃浠惰ˉ鍒扮浉搴旂殑澶у皬锛屼篃鍙兘鏄互涓浜涢殢鏈虹殑鍐呭鍔犱笂鍘汇? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 //www.cnblogs.com/allenblogs/archive/2010/09/13/1824842.html //www.cnblogs.com/rollenholt/archive/2012/04/23/2466179.html<img src ="//www.cqk4s.cn/xzclog/aggbug/433526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.cqk4s.cn/xzclog/" target="_blank">xzc</a> 2018-11-28 11:52 <a href="//www.cqk4s.cn/xzclog/archive/2018/11/28/433526.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>HDFS鍓湰璁剧疆鈥斺旈粯璁? - ▼幸运赛车规则▼幸运赛车投注▼幸运赛车开奖结果查询▼湖南幸运赛车开奖奖金▼幸运赛车走势▼//www.cqk4s.cn/xzclog/archive/2018/11/26/433518.htmlxzcxzcMon, 26 Nov 2018 03:52:00 GMT//www.cqk4s.cn/xzclog/archive/2018/11/26/433518.html//www.cqk4s.cn/xzclog/comments/433518.html//www.cqk4s.cn/xzclog/archive/2018/11/26/433518.html#Feedback0//www.cqk4s.cn/xzclog/comments/commentRss/433518.html//www.cqk4s.cn/xzclog/services/trackbacks/433518.html

xzc 2018-11-26 11:52 鍙戣〃璇勮
]]>
褰撳悓鏃跺畨瑁匬ython2鍜孭ython3鍚庯紝濡備綍鍏煎骞跺垏鎹娇鐢ㄨ瑙o紙姣斿pip浣跨敤锛?/title><link>//www.cqk4s.cn/xzclog/archive/2018/11/16/433500.html</link><dc:creator>xzc</dc:creator><author>xzc</author><pubDate>Fri, 16 Nov 2018 01:38:00 GMT</pubDate><guid>//www.cqk4s.cn/xzclog/archive/2018/11/16/433500.html</guid><wfw:comment>//www.cqk4s.cn/xzclog/comments/433500.html</wfw:comment><comments>//www.cqk4s.cn/xzclog/archive/2018/11/16/433500.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.cqk4s.cn/xzclog/comments/commentRss/433500.html</wfw:commentRss><trackback:ping>//www.cqk4s.cn/xzclog/services/trackbacks/433500.html</trackback:ping><description><![CDATA[杞嚜锛歨ttps://www.cnblogs.com/shabbylee/p/6792555.html 鐢变簬鍘嗗彶鍘熷洜锛孭ython鏈変袱涓ぇ鐨勭増鏈垎鏀紝Python2鍜孭ython3锛屽張鐢变簬涓浜涘簱鍙敮鎸佹煇涓増鏈垎鏀紝鎵浠ラ渶瑕佸湪鐢佃剳涓婂悓鏃跺畨瑁匬ython2鍜孭ython3锛屽洜姝ゅ浣曡涓や釜鐗堟湰鐨凱ython鍏煎锛屽浣曡鑴氭湰鍦ㄥ搴旂殑Python鐗堟湰涓婅繍琛岋紝杩欎釜鏄煎緱鎬荤粨鐨勩? 瀵逛簬Ubuntu 16.04 LTS鐗堟湰鏉ヨ锛孭ython2锛?.7.12锛夊拰Python3锛?.5.2锛夐粯璁ゅ悓鏃跺畨瑁咃紝榛樿鐨刾ython鐗堟湰鏄?.7.12銆? 褰撶劧浣犱篃鍙互鐢╬ython2鏉ヨ皟鐢ㄣ? 濡傛灉鎯宠皟鐢╬ython3锛屽氨鐢╬ython3. 瀵逛簬Windows锛屽氨鏈夌偣澶嶆潅浜嗐傚洜涓轰笉璁簆ython2杩樻槸python3锛宲ython鍙墽琛屾枃浠堕兘鍙玴ython.exe锛屽湪cmd涓嬭緭鍏ython寰楀埌鐨勭増鏈彿鍙栧喅浜庣幆澧冨彉閲忛噷鍝釜鐗堟湰鐨刾ython璺緞鏇撮潬鍓嶏紝姣曠珶windows鏄寜鐓ч『搴忔煡鎵剧殑銆傛瘮濡傜幆澧冨彉閲忛噷鐨勯『搴忔槸杩欐牱鐨勶細 閭d箞cmd涓嬬殑python鐗堟湰灏辨槸2.7.12銆? 鍙嶄箣锛屽垯鏄痯ython3鐨勭増鏈彿銆? 杩欏氨甯︽潵涓涓棶棰樹簡锛屽鏋滀綘鎯崇敤python2杩愯涓涓剼鏈紝涓浼氫綘鍙堟兂鐢╬ython3杩愯鍙︿竴涓剼鏈紝浣犳庝箞鍋氾紵鏉ュ洖鏀圭幆澧冨彉閲忔樉鐒跺緢楹荤儲銆? 缃戜笂寰堝鍔炴硶姣旇緝绠鍗曠矖鏆达紝鎶婁袱涓猵ython.exe鏀瑰悕鍟婏紝涓涓敼鎴恜ython2.exe锛屼竴涓敼鎴恜ython3.exe銆傝繖鏍峰仛鍥虹劧鍙互锛屼絾淇敼鍙墽琛屾枃浠剁殑鏂瑰紡锛屾瘯绔熶笉鏄緢濂界殑鏂规硶銆? 鎴戜粩缁嗘煡鎵句簡涓浜沺ython鎶鏈枃?。锛屽彂鐜板彟澶栦竴涓垜瑙夊緱姣旇緝濂界殑瑙e喅鍔炴硶銆? 鍊熺敤py鐨勪竴涓弬鏁版潵璋冪敤涓嶅悓鐗堟湰鐨凱ython銆俻y -2璋冪敤python2锛宲y -3璋冪敤鐨勬槸python3. 褰損ython鑴氭湰闇瑕乸ython2杩愯鏃讹紝鍙渶鍦ㄨ剼鏈墠鍔犱笂锛岀劧鍚庤繍琛宲y xxx.py鍗冲彲銆? #! python2 褰損ython鑴氭湰闇瑕乸ython3杩愯鏃讹紝鍙渶鍦ㄨ剼鏈墠鍔犱笂锛岋紝鐒跺悗杩愯py xxx.py鍗冲彲銆? #! python3 灏辫繖涔堢畝鍗曘? 鍚屾椂锛岃繖涔熷畬缇庤В鍐充簡鍦╬ip鍦╬ython2鍜宲ython3鍏卞瓨鐨勭幆澧冧笅鎶ラ敊锛屾彁绀篎atal error in launcher: Unable to create process using '"'鐨勯棶棰樸? 褰撻渶瑕乸ython2鐨刾ip鏃讹紝鍙渶 py -2 -m pip install xxx 褰撻渶瑕乸ython3鐨刾ip鏃讹紝鍙渶 py -3 -m pip install xxx python2鍜宲ython3鐨刾ip package灏辫繖鏍峰彲浠ュ畬缇庡垎寮浜嗐?img src ="//www.cqk4s.cn/xzclog/aggbug/433500.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.cqk4s.cn/xzclog/" target="_blank">xzc</a> 2018-11-16 09:38 <a href="//www.cqk4s.cn/xzclog/archive/2018/11/16/433500.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>hive闆嗘垚sentry鐨剆ql鐢ㄦ硶銆?/title><link>//www.cqk4s.cn/xzclog/archive/2018/09/03/433353.html</link><dc:creator>xzc</dc:creator><author>xzc</author><pubDate>Mon, 03 Sep 2018 10:19:00 GMT</pubDate><guid>//www.cqk4s.cn/xzclog/archive/2018/09/03/433353.html</guid><wfw:comment>//www.cqk4s.cn/xzclog/comments/433353.html</wfw:comment><comments>//www.cqk4s.cn/xzclog/archive/2018/09/03/433353.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.cqk4s.cn/xzclog/comments/commentRss/433353.html</wfw:commentRss><trackback:ping>//www.cqk4s.cn/xzclog/services/trackbacks/433353.html</trackback:ping><description><![CDATA[ Sentry鏉冮檺鎺у埗閫氳繃Beeline锛圚iveserver2 SQL 鍛戒护琛屾帴鍙o級杈撳叆Grant 鍜?Revoke璇彞鏉ラ厤缃傝娉曡窡鐜板湪鐨勪竴浜涗富娴佺殑鍏崇郴鏁版嵁搴撳緢鐩镐技銆傞渶瑕佹敞鎰忕殑鏄細褰搒entry鏈嶅姟鍚敤鍚庯紝鎴戜滑蹇呴』浣跨敤beeline鎺ュ彛鏉ユ墽琛宧ive鏌ヨ锛孒ive Cli骞朵笉鏀寔sentry銆? CREATE ROLE Statement CREATE ROLE璇彞鍒涘缓涓涓彲浠ヨ璧嬫潈鐨勮鑹层傛潈闄愬彲浠ヨ祴缁欒鑹诧紝鐒跺悗鍐嶅垎閰嶇粰鍚勪釜鐢ㄦ埛銆備竴涓敤鎴疯鍒嗛厤鍒拌鑹插悗鍙互鎵ц璇ヨ鑹茬殑鏉冮檺銆? 鍙湁鎷ユ湁绠$悊鍛樼殑瑙掕壊鍙互create/drop瑙掕壊銆傞粯璁ゆ儏鍐典笅锛宧ive銆乮mpala鍜宧ue鐢ㄦ埛鎷ユ湁绠$悊鍛樿鑹层? CREATE ROLE [role_name]; DROP ROLE Statement DROP ROLE璇彞鍙互鐢ㄦ潵浠庢暟鎹簱涓Щ闄や竴涓鑹层備竴鏃︾Щ闄わ紝涔嬪墠鍒嗛厤缁欐墍鏈夌敤鎴风殑璇ヨ鑹插皢浼氬彇娑堛備箣鍓嶅凡缁忔墽琛岀殑璇彞涓嶄細鍙楀埌褰卞搷銆備絾鏄紝鍥犱负hive鍦ㄦ墽琛屾瘡鏉℃煡璇㈣鍙ヤ箣鍓嶄細妫鏌ョ敤鎴风殑鏉冮檺锛屽浜庣櫥褰曟椿璺冪姸鎬佺殑鐢ㄦ埛浼氳瘽浼氬彈鍒板奖鍝嶃? DROP ROLE [role_name]; GRANT ROLE Statement GRANT ROLE璇彞鍙互鐢ㄦ潵缁欑粍鎺堜簣瑙掕壊銆傚彧鏈塻entry鐨勭鐞嗗憳鐢ㄦ埛鎵嶈兘鎵ц璇ユ搷浣溿? GRANT ROLE role_name [, role_name] TO GROUP 锛坓roupName锛?[,GROUP 锛坓roupName锛塢 REVOKE ROLE Statement REVOKE ROLE璇彞鍙互鐢ㄦ潵浠庣粍绉婚櫎瑙掕壊銆傚彧鏈塻entry鐨勭鐞嗗憳鐢ㄦ埛鎵嶈兘鎵ц璇ユ搷浣溿? REVOKE ROLE role_name [, role_name] FROM GROUP 锛坓roupName) [,GROUP (groupName)] GRANT (PRIVILEGE) Statement 鎺堜簣涓涓璞$殑鏉冮檺缁欎竴涓鑹诧紝璇ョ敤鎴峰繀椤讳负sentry鐨勭鐞嗗憳鐢ㄦ埛銆? GRANT (PRIVILEGE) [, (PRIVILEGE) ] ON (OBJECT) (object_name) TO ROLE (roleName) [,ROLE (roleName)] REVOKE 锛圥RIVILEGE锛?Statement 鍥犱负鍙湁璁よ瘉鐨勭鐞嗗憳鐢ㄦ埛鍙互鍒涘缓瑙掕壊锛屼粠鑰屽彧鏈夌鐞嗗憳鐢ㄦ埛鍙互鍙栨秷涓涓粍鐨勬潈闄愩? REVOKE (PRIVILEGE) [, (PRIVILEGE) ] ON (OBJECT) (object_name) FROM ROLE (roleName) [,ROLE (roleName)] GRANT (PRIVILEGE) ... WITH GRANT OPTION 鍦╟dh5.2涓紝浣犲彲浠ュ鎵樼粰鍏朵粬瑙掕壊鏉ユ巿浜堝拰瑙i櫎鏉冮檺銆傛瘮濡傦紝涓涓鑹茶鎺堜簣浜哤ITH GRANT OPTION鐨勬潈闄愬彲浠RANT/REVOKE鍚屾牱鐨勬潈闄愮粰鍏朵粬瑙掕壊銆傚洜姝わ紝濡傛灉涓涓鑹叉湁涓涓簱鐨勬墍鏈夋潈闄愬苟涓旇缃簡 WITH GRANT OPTION锛岃瑙掕壊鍒嗛厤鐨勭敤鎴峰彲浠ュ璇ユ暟鎹簱鍜屽叾涓殑琛ㄦ墽琛孏RANT/REVOKE璇彞銆? GRANT 锛圥RIVILEGE锛? ON 锛圤BJECT锛?锛坥bject_name锛? TO ROLE 锛坮oleName锛? WITH GRANT OPTION 鍙湁涓涓甫GRANT閫夐」鐨勭壒娈婃潈闄愮殑瑙掕壊鎴栬呭畠鐨勭埗绾ф潈闄愬彲浠ヤ粠鍏朵粬瑙掕壊瑙i櫎杩欑鏉冮檺銆備竴鏃︿笅闈㈢殑璇彞鎵ц锛屾墍鏈夎窡鍏剁浉鍏崇殑grant鏉冮檺灏嗕細琚В闄ゃ? REVOKE 锛圧IVILEGE锛? ON 锛圔JECT锛?锛坆ject_name锛? FROM ROLE 锛坮oleName锛? Hive鐩墠涓嶆敮鎸佽В闄や箣鍓嶈祴浜堜竴涓鑹?WITH GRANT OPTION 鐨勬潈闄愩傝鎯崇Щ闄ITH GRANT OPTION銆佽В闄ゆ潈闄愶紝鍙互閲嶆柊鍘婚櫎 WITH GRANT OPTION杩欎釜鏍囪鏉ュ啀娆¢檮鏉冦? SET ROLE Statement SET ROLE璇彞鍙互缁欏綋鍓嶄細璇濋夋嫨涓涓鑹蹭娇涔嬬敓鏁堛備竴涓敤鎴峰彧鑳藉惎鐢ㄥ垎閰嶇粰浠栫殑瑙掕壊銆備换浣曚笉瀛樺湪鐨勮鑹插拰褰撳墠鐢ㄦ埛涓嶈兘浣跨敤鐨勮鑹叉槸涓嶈兘鐢熸晥鐨勩傚鏋滄病鏈変娇鐢ㄤ换浣曡鑹诧紝鐢ㄦ埛灏嗕細浣跨敤浠讳綍涓涓睘浜庝粬鐨勮鑹茬殑鏉冮檺銆? 閫夋嫨涓涓鑹蹭娇鐢細 To enable a specific role: 浣跨敤鎵鏈夌殑瑙掕壊锛? To enable a specific role: 鍏抽棴鎵鏈夎鑹? SET ROLE NONE; SHOW Statement 鏄剧ず褰撳墠鐢ㄦ埛鎷ユ湁搴撱佽〃銆佸垪鐩稿叧鏉冮檺鐨勬暟鎹簱锛? SHOW DATABASES; 鏄剧ず褰撳墠鐢ㄦ埛鎷ユ湁琛ㄣ佸垪鐩稿叧鏉冮檺鐨勮〃锛? SHOW TABLES; 鏄剧ず褰撳墠鐢ㄦ埛鎷ユ湁SELECT鏉冮檺鐨勫垪锛? SHOW COLUMNS (FROM|IN) table_name [(FROM|IN) db_name]; 鏄剧ず褰撳墠绯荤粺涓墍鏈夌殑瑙掕壊锛堝彧鏈夌鐞嗗憳鐢ㄦ埛鍙互鎵ц锛夛細 SHOW ROLES; 鏄剧ず褰撳墠褰卞搷褰撳墠浼氳瘽鐨勮鑹诧細 SHOW CURRENT ROLES; 鏄剧ず鎸囧畾缁勭殑琚垎閰嶅埌鐨勬墍鏈夎鑹诧紙鍙湁绠$悊鍛樼敤鎴峰拰鎸囧畾缁勫唴鐨勭敤鎴峰彲浠ユ墽琛岋級 SHOW ROLE GRANT GROUP (groupName); SHOW璇彞鍙互鐢ㄦ潵鏄剧ず涓涓鑹茶鎺堜簣鐨勬潈闄愭垨鑰呮樉绀鸿鑹茬殑涓涓壒瀹氬璞$殑鎵鏈夋潈闄愩? 鏄剧ず鎸囧畾瑙掕壊鐨勬墍鏈夎璧嬩簣鐨勬潈闄愩傦紙鍙湁绠$悊鍛樼敤鎴峰拰鎸囧畾瑙掕壊鍒嗛厤鍒扮殑鐢ㄦ埛鍙互鎵ц锛夈備笅闈㈢殑璇彞涔熶細鏄剧ず浠讳綍鍒楃骇鐨勬潈闄愩? SHOW GRANT ROLE (roleName); 鏄剧ず鎸囧畾瀵硅薄鐨勪竴涓鑹茬殑鎵鏈夎璧嬩簣鐨勬潈闄愶紙鍙湁绠$悊鍛樼敤鎴峰拰鎸囧畾瑙掕壊鍒嗛厤鍒扮殑鐢ㄦ埛鍙互鎵ц锛夈備笅闈㈢殑璇彞涔熶細鏄剧ず浠讳綍鍒楃骇鐨勬潈闄愩? SHOW GRANT ROLE (roleName) on (OBJECT) (objectName); ----------------------------鎴戜篃鏄湁搴曠嚎鐨?----------------------------<img src ="//www.cqk4s.cn/xzclog/aggbug/433353.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.cqk4s.cn/xzclog/" target="_blank">xzc</a> 2018-09-03 18:19 <a href="//www.cqk4s.cn/xzclog/archive/2018/09/03/433353.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Python缂栫爜鍜岃В鐮?/title><link>//www.cqk4s.cn/xzclog/archive/2018/05/18/433218.html</link><dc:creator>xzc</dc:creator><author>xzc</author><pubDate>Fri, 18 May 2018 01:52:00 GMT</pubDate><guid>//www.cqk4s.cn/xzclog/archive/2018/05/18/433218.html</guid><wfw:comment>//www.cqk4s.cn/xzclog/comments/433218.html</wfw:comment><comments>//www.cqk4s.cn/xzclog/archive/2018/05/18/433218.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.cqk4s.cn/xzclog/comments/commentRss/433218.html</wfw:commentRss><trackback:ping>//www.cqk4s.cn/xzclog/services/trackbacks/433218.html</trackback:ping><description><![CDATA[     鎽樿: Python 閲岄潰鐨勭紪鐮佸拰瑙g爜涔熷氨鏄?nbsp;unicode 鍜?nbsp;str 杩欎袱绉嶅舰寮忕殑鐩镐簰杞寲銆傜紪鐮佹槸 unicode -> str锛岀浉鍙嶇殑锛岃В鐮佸氨鏄?nbsp;str -> unicode銆傚墿涓嬬殑闂灏辨槸纭畾浣曟椂闇瑕佽繘琛岀紪鐮佹垨鑰呰В鐮佷簡.鍏充簬鏂囦欢寮澶寸殑"缂栫爜鎸囩ず"锛屼篃灏辨槸 # -*- codin...  <a href='//www.cqk4s.cn/xzclog/archive/2018/05/18/433218.html'>闃呰鍏ㄦ枃</a><img src ="//www.cqk4s.cn/xzclog/aggbug/433218.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.cqk4s.cn/xzclog/" target="_blank">xzc</a> 2018-05-18 09:52 <a href="//www.cqk4s.cn/xzclog/archive/2018/05/18/433218.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>kafka鑺傜偣鍋囨 - ▼幸运赛车规则▼幸运赛车投注▼幸运赛车开奖结果查询▼湖南幸运赛车开奖奖金▼幸运赛车走势▼//www.cqk4s.cn/xzclog/archive/2018/03/08/433087.htmlxzcxzcThu, 08 Mar 2018 08:35:00 GMT//www.cqk4s.cn/xzclog/archive/2018/03/08/433087.html//www.cqk4s.cn/xzclog/comments/433087.html//www.cqk4s.cn/xzclog/archive/2018/03/08/433087.html#Feedback0//www.cqk4s.cn/xzclog/comments/commentRss/433087.html//www.cqk4s.cn/xzclog/services/trackbacks/433087.html
涓銆佸墠瑷
    鏃╀笂閱掓潵鎵撳紑寰俊锛屽悓浜嬪弽棣坘afka闆嗙兢浠庢槰澶╁噷鏅ㄥ紑濮嬪啓鍏ラ绻佸け璐ワ紝璧剁揣鎵撳紑鐢佃剳鏌ョ湅浜唊afka闆嗙兢鐨勬満鍣ㄧ洃鎺э紝鏃ュ織淇℃伅锛屽彂鐜板叾涓竴涓妭鐐圭殑闆嗙兢璐熻浇浠庢槰澶╁噷鏅ㄧ獊鐒舵帀涓嬫潵浜嗭紝鍜屽悓浜嬪弽棣堢殑鏃堕棿鐐瑰ぇ姒備竴鑷达紝浜庢槸涔庡氨鐧诲綍鏈嶅姟鍣ㄥ紑濮嬪共娲汇?/div>
浜屻佹帓閿?/div>
1銆佹煡鐪嬫満鍣ㄧ洃鎺э紝鐪嬫槸鍚﹁兘澶ф瀹氫綅鏄摢涓妭鐐规湁寮傚父
鎶鏈垎浜?/div>
2銆佹牴鎹満鍣ㄧ洃鎺уぇ姒傚畾浣嶅埌鍏朵腑涓涓紓甯歌妭鐐癸紝鐧诲綍鏈嶅姟鍣ㄦ煡鐪媖afka鏃ュ織锛屽彂鐜版湁鎶ラ敊鏃ュ織锛屽苟涓旀棩蹇楀氨鍋滅暀鍦ㄨ繖涓繖涓椂闂寸偣锛?/div>
[2017-06-01 16:59:59,851] ERROR Processor got uncaught exception. (kafka.network.Processor)
java.lang.OutOfMemoryError: Direct buffer memory
        at java.nio.Bits.reserveMemory(Bits.java:658)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
        at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:174)
        at sun.nio.ch.IOUtil.read(IOUtil.java:195)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
        at org.apache.kafka.common.network.PlaintextTransportLayer.read(PlaintextTransportLayer.java:108)
        at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:97)
        at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:71)
        at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:160)
        at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:141)
        at org.apache.kafka.common.network.Selector.poll(Selector.java:286)
        at kafka.network.Processor.run(SocketServer.scala:413)3銆佹煡鐪媖afka杩涚▼鍜岀洃鍚鍙f儏鍐碉紝鍙戠幇閮芥甯革紝灏肩帥鍋囨浜?/div>
ps -ef |grep kafka        ## 鏌ョ湅kafka鐨勮繘绋?/div>
netstat -ntlp |grep 9092  ##9092kafka鐨勭洃鍚鍙?銆佹棦鐒跺凡缁忓亣姝讳簡锛屽彧鑳介噸鍚簡
ps -ef |grep kafka |grep -v grep |awk ‘{print $2}‘  | xargs kill -9  
/usr/local/kafka/bin;nohup ./kafka-server-start.sh ../config/server.properties &5銆侀噸鍚悗鍦ㄨ瀵熻鑺傜偣鐨刱afka鏃ュ織锛屽湪涓椤縤ndex閲嶅缓涔嬪悗锛屼笂闈㈢殑鎶ラ敊淇℃伅鍦ㄧ柉鐙傜殑鍒凤紝鏈鍚庤胺姝屼竴鐣紝瑙e喅浜嗚闂
涓夈佽В鍐虫柟妗堬細
鍦?/div>
/usr/local/kafka/binkafka-run-class.sh鍘绘帀
-XX:+DisableExplicitGC娣诲姞
-XX:MaxDirectMemorySize=512m鍦ㄤ竴娆¢噸鍚痥afka锛岄棶棰樿В鍐炽?/div>


xzc 2018-03-08 16:35 鍙戣〃璇勮
]]>Hive涓璻educe涓暟璁惧畾 - ▼幸运赛车规则▼幸运赛车投注▼幸运赛车开奖结果查询▼湖南幸运赛车开奖奖金▼幸运赛车走势▼//www.cqk4s.cn/xzclog/archive/2018/03/07/433084.htmlxzcxzcWed, 07 Mar 2018 03:21:00 GMT//www.cqk4s.cn/xzclog/archive/2018/03/07/433084.html//www.cqk4s.cn/xzclog/comments/433084.html//www.cqk4s.cn/xzclog/archive/2018/03/07/433084.html#Feedback1//www.cqk4s.cn/xzclog/comments/commentRss/433084.html//www.cqk4s.cn/xzclog/services/trackbacks/433084.html闃呰鍏ㄦ枃

xzc 2018-03-07 11:21 鍙戣〃璇勮
]]>
spark 绱姞鍘嗗彶 + 缁熻鍏ㄩ儴 + 琛岃浆鍒?/title><link>//www.cqk4s.cn/xzclog/archive/2017/10/23/432867.html</link><dc:creator>xzc</dc:creator><author>xzc</author><pubDate>Mon, 23 Oct 2017 14:05:00 GMT</pubDate><guid>//www.cqk4s.cn/xzclog/archive/2017/10/23/432867.html</guid><wfw:comment>//www.cqk4s.cn/xzclog/comments/432867.html</wfw:comment><comments>//www.cqk4s.cn/xzclog/archive/2017/10/23/432867.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.cqk4s.cn/xzclog/comments/commentRss/432867.html</wfw:commentRss><trackback:ping>//www.cqk4s.cn/xzclog/services/trackbacks/432867.html</trackback:ping><description><![CDATA[     鎽樿: spark 绱姞鍘嗗彶涓昏鐢ㄥ埌浜嗙獥鍙e嚱鏁帮紝鑰岃繘琛屽叏閮ㄧ粺璁★紝鍒欓渶瑕佺敤鍒皉ollup鍑芥暟 1  搴旂敤鍦烘櫙锛?銆銆1銆佹垜浠渶瑕佺粺璁$敤鎴风殑鎬讳娇鐢ㄦ椂闀匡紙绱姞鍘嗗彶锛?銆銆2銆佸墠鍙板睍鐜伴〉闈㈤渶瑕佸澶氫釜缁村害杩涜鏌ヨ锛屽锛氫骇鍝併佸湴鍖虹瓑绛?銆銆3銆侀渶瑕佸睍鐜扮殑琛ㄦ牸澶村锛?浜у搧銆?015-04銆?015-05銆?015-06 2 鍘熷鏁版嵁锛? product_code |event_date |dur...  <a href='//www.cqk4s.cn/xzclog/archive/2017/10/23/432867.html'>闃呰鍏ㄦ枃</a><img src ="//www.cqk4s.cn/xzclog/aggbug/432867.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.cqk4s.cn/xzclog/" target="_blank">xzc</a> 2017-10-23 22:05 <a href="//www.cqk4s.cn/xzclog/archive/2017/10/23/432867.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Spark鍒嗘瀽绐楀彛鍑芥暟 - ▼幸运赛车规则▼幸运赛车投注▼幸运赛车开奖结果查询▼湖南幸运赛车开奖奖金▼幸运赛车走势▼//www.cqk4s.cn/xzclog/archive/2017/10/23/432866.htmlxzcxzcMon, 23 Oct 2017 14:04:00 GMT//www.cqk4s.cn/xzclog/archive/2017/10/23/432866.html//www.cqk4s.cn/xzclog/comments/432866.html//www.cqk4s.cn/xzclog/archive/2017/10/23/432866.html#Feedback0//www.cqk4s.cn/xzclog/comments/commentRss/432866.html//www.cqk4s.cn/xzclog/services/trackbacks/432866.html闃呰鍏ㄦ枃

xzc 2017-10-23 22:04 鍙戣〃璇勮
]]>
SparkSQL鐩稿叧璇彞鎬荤粨 - ▼幸运赛车规则▼幸运赛车投注▼幸运赛车开奖结果查询▼湖南幸运赛车开奖奖金▼幸运赛车走势▼//www.cqk4s.cn/xzclog/archive/2017/10/23/432865.htmlxzcxzcMon, 23 Oct 2017 13:03:00 GMT//www.cqk4s.cn/xzclog/archive/2017/10/23/432865.html//www.cqk4s.cn/xzclog/comments/432865.html//www.cqk4s.cn/xzclog/archive/2017/10/23/432865.html#Feedback0//www.cqk4s.cn/xzclog/comments/commentRss/432865.html//www.cqk4s.cn/xzclog/services/trackbacks/432865.html湖南赛车电视走势图:SparkSQL鐩稿叧璇彞鎬荤粨

1.in 涓嶆敮鎸佸瓙鏌ヨ eg. select * from src where key in(select key from test);
鏀寔鏌ヨ涓暟 eg. select * from src where key in(1,2,3,4,5);
in 40000涓?鑰楁椂25.766绉?br />in 80000涓?鑰楁椂78.827绉?br />
2.union all/union
涓嶆敮鎸侀《灞傜殑union all eg. select key from src UNION ALL select key from test;
鏀寔select * from (select key from src union all select key from test)aa;
涓嶆敮鎸?union
鏀寔select distinct key from (select key from src union all select key from test)aa;

3.intersect 涓嶆敮鎸?/strong>

4.minus 涓嶆敮鎸?/strong>

5.except 涓嶆敮鎸?/strong>

6.inner join/join/left outer join/right outer join/full outer join/left semi join 閮芥敮鎸?/strong>
left outer join/right outer join/full outer join 涓棿蹇呴』鏈塷uter
join鏄渶绠鍗曠殑鍏宠仈鎿嶄綔锛屼袱杈瑰叧鑱斿彧鍙栦氦闆?
left outer join鏄互宸﹁〃椹卞姩锛屽彸琛ㄤ笉瀛樺湪鐨刱ey鍧囪祴鍊间负null锛?br />right outer join鏄互鍙宠〃椹卞姩锛屽乏琛ㄤ笉瀛樺湪鐨刱ey鍧囪祴鍊间负null锛?br />full outer join鍏ㄨ〃鍏宠仈锛屽皢涓よ〃瀹屾暣鐨勮繘琛岀瑳鍗″皵绉搷浣滐紝宸﹀彸琛ㄥ潎鍙祴鍊间负null;
left semi join鏈涓昏鐨勪娇鐢ㄥ満鏅氨鏄В鍐砮xist in;
Hive涓嶆敮鎸亀here瀛愬彞涓殑瀛愭煡璇紝SQL甯哥敤鐨別xist in瀛愬彞鍦℉ive涓槸涓嶆敮鎸佺殑
涓嶆敮鎸佸瓙鏌ヨ eg. select * from src aa where aa.key in(select bb.key from test bb);
鍙敤浠ヤ笅涓ょ鏂瑰紡鏇挎崲锛?br />select * from src aa left outer join test bb on aa.key=bb.key where bb.key <> null;
select * from src aa left semi join test bb on aa.key=bb.key;
澶у鏁版儏鍐典笅 JOIN ON 鍜?left semi on 鏄绛夌殑
A,B涓よ〃杩炴帴锛屽鏋淏琛ㄥ瓨鍦ㄩ噸澶嶆暟鎹?br />褰撲娇鐢↗OIN ON鐨勬椂鍊欙紝A,B琛ㄤ細鍏宠仈鍑轰袱鏉¤褰曪紝搴斾负ON涓婄殑鏉′欢绗﹀悎锛?span class="Apple-converted-space"> 
鑰屾槸鐢↙EFT SEMI JOIN 褰揂琛ㄤ腑鐨勮褰曪紝鍦˙琛ㄤ笂浜х敓绗﹀悎鏉′欢涔嬪悗灏辫繑鍥烇紝涓嶄細鍐嶇户缁煡鎵綛琛ㄨ褰曚簡锛?br />鎵浠ュ鏋淏琛ㄦ湁閲嶅锛屼篃涓嶄細浜х敓閲嶅鐨勫鏉¤褰曘?span class="Apple-converted-space"> 
left outer join 鏀寔瀛愭煡璇?eg. select aa.* from src aa left outer join (select * from test111)bb on aa.key=bb.a;

7. hive鍥涗腑鏁版嵁瀵煎叆鏂瑰紡
1锛?strong>浠庢湰鍦版枃浠剁郴缁熶腑瀵煎叆鏁版嵁鍒癏ive琛?/strong>
create table wyp(id int,name string) ROW FORMAT delimited fields terminated by '\t' STORED AS TEXTFILE;
load data local inpath 'wyp.txt' into table wyp;
2)浠嶩DFS涓婂鍏ユ暟鎹埌Hive琛?/strong>
[wyp@master /home/q/hadoop-2.2.0]$ bin/hadoop fs -cat /home/wyp/add.txt
hive> load data inpath '/home/wyp/add.txt' into table wyp;
3)浠庡埆鐨勮〃涓煡璇㈠嚭鐩稿簲鐨勬暟鎹苟瀵煎叆鍒癏ive琛ㄤ腑
hive> create table test(
> id int, name string
> ,tel string)
> partitioned by
> (age int)
> ROW FORMAT DELIMITED
> FIELDS TERMINATED BY '\t'
> STORED AS TEXTFILE;

娉細test琛ㄩ噷闈㈢敤age浣滀负浜嗗垎鍖哄瓧娈碉紝鍒嗗尯锛氬湪Hive涓紝琛ㄧ殑姣忎竴涓垎鍖哄搴旇〃涓嬬殑鐩稿簲鐩綍锛屾墍鏈夊垎鍖虹殑鏁版嵁閮芥槸瀛樺偍鍦ㄥ搴旂殑鐩綍涓?br />姣斿wyp琛ㄦ湁dt鍜宑ity涓や釜鍒嗗尯锛屽垯瀵瑰簲dt=20131218city=BJ瀵瑰簲琛ㄧ殑鐩綍涓?user/hive/warehouse/dt=20131218/city=BJ锛?br />鎵鏈夊睘浜庤繖涓垎鍖虹殑鏁版嵁閮藉瓨鏀惧湪杩欎釜鐩綍涓?br />
hive> insert into table test
> partition (age='25')
> select id, name, tel
> from wyp;

涔熷彲浠ュ湪select璇彞閲岄潰閫氳繃浣跨敤鍒嗗尯鍊兼潵鍔ㄦ佹寚鏄庡垎鍖猴細
hive> set hive.exec.dynamic.partition.mode=nonstrict;
hive> insert into table test
> partition (age)
> select id, name,
> tel, age
> from wyp;

Hive涔熸敮鎸乮nsert overwrite鏂瑰紡鏉ユ彃鍏ユ暟鎹?/strong>
hive> insert overwrite table test
> PARTITION (age)
> select id, name, tel, age
> from wyp;

Hive杩樻敮鎸佸琛ㄦ彃鍏?br />hive> from wyp
> insert into table test
> partition(age)
> select id, name, tel, age
> insert into table test3
> select id, name
> where age>25;
4)鍦ㄥ垱寤鸿〃鐨勬椂鍊欓氳繃浠庡埆鐨勮〃涓煡璇㈠嚭鐩稿簲鐨勮褰曞苟鎻掑叆鍒版墍鍒涘缓鐨勮〃涓?/strong>
hive> create table test4
> as
> select id, name, tel
> from wyp;

8.鏌ョ湅寤鸿〃璇彞
hive> show create table test3;

9.琛ㄩ噸鍛藉悕
hive> ALTER TABLE events RENAME TO 3koobecaf; 

10.琛ㄥ鍔犲垪
hive> ALTER TABLE pokes ADD COLUMNS (new_col INT); 

11.娣诲姞涓鍒楀苟澧炲姞鍒楀瓧娈垫敞閲?/strong> 
hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 'a comment'); 

12.鍒犻櫎琛?/strong>
hive> DROP TABLE pokes; 

13.top n
hive> select * from test order by key limit 10;
14.鍒涘缓鏁版嵁搴?/strong>
Create Database baseball;

14.alter table tablename  change oldColumn newColumn column_type 淇敼鍒楃殑鍚嶇О鍜岀被鍨?/strong>

alter table yangsy CHANGE product_no phone_no string

 

15.瀵煎叆.sql鏂囦欢涓殑sql

 spark-sql --driver-class-path /home/hadoop/hive/lib/mysql-connector-java-5.1.30-bin.jar -f testsql.sql 


insert into table CI_CUSER_20141117154351522 select mainResult.PRODUCT_NO,dw_coclbl_m02_3848.L1_01_02_01,dw_coclbl_d01_3845.L2_01_01_04 from (select PRODUCT_NO from CI_CUSER_20141114203632267) mainResult left join DW_COCLBL_M02_201407 dw_coclbl_m02_3848 on mainResult.PRODUCT_NO = dw_coclbl_m02_3848.PRODUCT_NO left join DW_COCLBL_D01_20140515 dw_coclbl_d01_3845 on dw_coclbl_m02_3848.PRODUCT_NO = dw_coclbl_d01_3845.PRODUCT_NO

insert into CI_CUSER_20141117142123638 ( PRODUCT_NO,ATTR_COL_0000,ATTR_COL_0001) select mainResult.PRODUCT_NO,dw_coclbl_m02_3848.L1_01_02_01,dw_coclbl_m02_3848.L1_01_03_01 from (select PRODUCT_NO from CI_CUSER_20141114203632267) mainResult left join DW_COCLBL_M02_201407 dw_coclbl_m02_3848 on mainResult.PRODUCT_NO = dw_coclbl_m02_3848.PRODUCT_NO 


CREATE TABLE ci_cuser_yymmddhhmisstttttt_tmp(product_no string) row format serde 'com.bizo.hive.serde.csv.CSVSerde' ; 
LOAD DATA LOCAL INPATH '/home/ocdc/coc/yuli/test123.csv' OVERWRITE INTO TABLE test_yuli2;

鍒涘缓鏀寔CSV鏍煎紡鐨則estfile鏂囦欢
CREATE TABLE test_yuli7 row format serde 'com.bizo.hive.serde.csv.CSVSerde' as select * from CI_CUSER_20150310162729786;

涓嶄緷璧朇SVSerde鐨刯ar鍖呭垱寤洪楀彿鍒嗛殧鐨勮〃
"create table " +listName+ " ROW FORMAT DELIMITED FIELDS TERMINATED BY ','" +
" as select * from " + listName1;

create table aaaa ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' STORED AS TEXTFILE as select * from

ThriftServer 寮鍚疐AIR妯″紡
SparkSQL Thrift Server 寮鍚疐AIR璋冨害鏂瑰紡:
1. 淇敼$SPARK_HOME/conf/spark-defaults.conf,鏂板
2. spark.scheduler.mode FAIR
3. spark.scheduler.allocation.file /Users/tianyi/github/community/apache-spark/conf/fair-scheduler.xml
4. 淇敼$SPARK_HOME/conf/fair-scheduler.xml(鎴栨柊澧炶鏂囦欢), 缂栬緫濡備笅鏍煎紡鍐呭
5. <?xml version="1.0"?>
6. <allocations>
7. <pool name="production">
8. <schedulingMode>FAIR</schedulingMode>
9. <!-- weight琛ㄧず涓や釜闃熷垪鍦╩inShare鐩稿悓鐨勬儏鍐典笅,鍙互浣跨敤璧勬簮鐨勬瘮渚?-->
10. <weight>1</weight>
11. <!-- minShare琛ㄧず浼樺厛淇濊瘉鐨勮祫婧愭暟 -->
12. <minShare>2</minShare>
13. </pool>
14. <pool name="test">
15. <schedulingMode>FIFO</schedulingMode>
16. <weight>2</weight>
17. <minShare>3</minShare>
18. </pool>
19. </allocations>
20. 閲嶅惎Thrift Server
21. 鎵цSQL鍓?鎵ц 
22. set spark.sql.thriftserver.scheduler.pool=鎸囧畾鐨勯槦鍒楀悕

绛夋搷浣滃畬浜?create table yangsy555 like CI_CUSER_YYMMDDHHMISSTTTTTT 鐒跺悗insert into yangsy555 select * from yangsy555

 

鍒涘缓涓涓嚜澧炲簭鍒楄〃锛屼娇鐢╮ow_number() over()涓鸿〃澧炲姞搴忓垪鍙?浠ヤ緵鍒嗛〉鏌ヨ

create table yagnsytest2 as SELECT ROW_NUMBER() OVER() as id,* from yangsytest;

 

 

Sparksql鐨勮В鏋愪笌Hiveql鐨勮В鏋愮殑鎵ц娴佺▼:



]]>
  • 苹果-热门标签-华商生活 2019-03-10
  • “奥运新秀”亮相上海 亚帆联杯等你来看 2019-03-07
  • 蔡奇就历史文化遗产保护调研:把燕都金中都建设保护好 2019-02-23
  • 红曲美的绿盒子,绿色生活大不同 2019-02-23
  • 理发迎接世界杯 梅西粉丝将偶像笑脸“抛在脑后” 2018-11-26
  • 我省各类创业孵化载体累计“毕业”企业3054家 2018-11-26
  • 鸿山慈善会厦门佛事展举行义诊活动 赢得群众交口称赞 2018-11-24
  • 特色小镇里的税收服务 定海国地税多措并举提升效能 2018-11-24
  • 端午小长假我市旅游总收入同比增20.5% 2018-08-12
  • [微笑]其实很简单就能破这个局:立法禁止通过房地产二次交易获利,炒房就会被杜绝,炒房一旦被杜绝,房价就会受正常供需关系影响波动在合理范围内。 2018-08-12