锘??xml version="1.0" encoding="utf-8" standalone="yes"?>三国杀官网百度一区:BlogJava - 4399三国杀ol官网|三国杀传奇武将//www.lmlez.icu/xzclog/zh-cnWed, 16 Oct 2019 03:18:36 GMTWed, 16 Oct 2019 03:18:36 GMT60Python璇誨啓銆佸垱寤烘枃浠?/title><link>//www.lmlez.icu/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.lmlez.icu/xzclog/archive/2018/11/28/433526.html</guid><wfw:comment>//www.lmlez.icu/xzclog/comments/433526.html</wfw:comment><comments>//www.lmlez.icu/xzclog/archive/2018/11/28/433526.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.lmlez.icu/xzclog/comments/commentRss/433526.html</wfw:commentRss><trackback:ping>//www.lmlez.icu/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.lmlez.icu/xzclog/aggbug/433526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.lmlez.icu/xzclog/" target="_blank">xzc</a> 2018-11-28 11:52 <a href="//www.lmlez.icu/xzclog/archive/2018/11/28/433526.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>HDFS鍓湰璁劇疆鈥斺旈粯璁? - 4399三国杀ol官网|三国杀传奇武将//www.lmlez.icu/xzclog/archive/2018/11/26/433518.htmlxzcxzcMon, 26 Nov 2018 03:52:00 GMT//www.lmlez.icu/xzclog/archive/2018/11/26/433518.html//www.lmlez.icu/xzclog/comments/433518.html//www.lmlez.icu/xzclog/archive/2018/11/26/433518.html#Feedback0//www.lmlez.icu/xzclog/comments/commentRss/433518.html//www.lmlez.icu/xzclog/services/trackbacks/433518.html

xzc 2018-11-26 11:52 鍙戣〃璇勮
]]>
褰撳悓鏃跺畨瑁匬ython2鍜孭ython3鍚庯紝濡備綍鍏煎騫跺垏鎹嬌鐢ㄨ瑙o紙姣斿pip浣跨敤錛?/title><link>//www.lmlez.icu/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.lmlez.icu/xzclog/archive/2018/11/16/433500.html</guid><wfw:comment>//www.lmlez.icu/xzclog/comments/433500.html</wfw:comment><comments>//www.lmlez.icu/xzclog/archive/2018/11/16/433500.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.lmlez.icu/xzclog/comments/commentRss/433500.html</wfw:commentRss><trackback:ping>//www.lmlez.icu/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.lmlez.icu/xzclog/aggbug/433500.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.lmlez.icu/xzclog/" target="_blank">xzc</a> 2018-11-16 09:38 <a href="//www.lmlez.icu/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.lmlez.icu/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.lmlez.icu/xzclog/archive/2018/09/03/433353.html</guid><wfw:comment>//www.lmlez.icu/xzclog/comments/433353.html</wfw:comment><comments>//www.lmlez.icu/xzclog/archive/2018/09/03/433353.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.lmlez.icu/xzclog/comments/commentRss/433353.html</wfw:commentRss><trackback:ping>//www.lmlez.icu/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.lmlez.icu/xzclog/aggbug/433353.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.lmlez.icu/xzclog/" target="_blank">xzc</a> 2018-09-03 18:19 <a href="//www.lmlez.icu/xzclog/archive/2018/09/03/433353.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Python緙栫爜鍜岃В鐮?/title><link>//www.lmlez.icu/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.lmlez.icu/xzclog/archive/2018/05/18/433218.html</guid><wfw:comment>//www.lmlez.icu/xzclog/comments/433218.html</wfw:comment><comments>//www.lmlez.icu/xzclog/archive/2018/05/18/433218.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.lmlez.icu/xzclog/comments/commentRss/433218.html</wfw:commentRss><trackback:ping>//www.lmlez.icu/xzclog/services/trackbacks/433218.html</trackback:ping><description><![CDATA[     鎽樿: Python 閲岄潰鐨勭紪鐮佸拰瑙g爜涔熷氨鏄?nbsp;unicode 鍜?nbsp;str 榪欎袱縐嶅艦寮忕殑鐩鎬簰杞寲銆傜紪鐮佹槸 unicode -> str錛岀浉鍙嶇殑錛岃В鐮佸氨鏄?nbsp;str -> unicode銆傚墿涓嬬殑闂灝辨槸紜畾浣曟椂闇瑕佽繘琛岀紪鐮佹垨鑰呰В鐮佷簡.鍏充簬鏂囦歡寮澶寸殑"緙栫爜鎸囩ず"錛屼篃灝辨槸 # -*- codin...  <a href='//www.lmlez.icu/xzclog/archive/2018/05/18/433218.html'>闃呰鍏ㄦ枃</a><img src ="//www.lmlez.icu/xzclog/aggbug/433218.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.lmlez.icu/xzclog/" target="_blank">xzc</a> 2018-05-18 09:52 <a href="//www.lmlez.icu/xzclog/archive/2018/05/18/433218.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>kafka鑺傜偣鍋囨 - 4399三国杀ol官网|三国杀传奇武将//www.lmlez.icu/xzclog/archive/2018/03/08/433087.htmlxzcxzcThu, 08 Mar 2018 08:35:00 GMT//www.lmlez.icu/xzclog/archive/2018/03/08/433087.html//www.lmlez.icu/xzclog/comments/433087.html//www.lmlez.icu/xzclog/archive/2018/03/08/433087.html#Feedback0//www.lmlez.icu/xzclog/comments/commentRss/433087.html//www.lmlez.icu/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涓暟璁懼畾 - 4399三国杀ol官网|三国杀传奇武将//www.lmlez.icu/xzclog/archive/2018/03/07/433084.htmlxzcxzcWed, 07 Mar 2018 03:21:00 GMT//www.lmlez.icu/xzclog/archive/2018/03/07/433084.html//www.lmlez.icu/xzclog/comments/433084.html//www.lmlez.icu/xzclog/archive/2018/03/07/433084.html#Feedback1//www.lmlez.icu/xzclog/comments/commentRss/433084.html//www.lmlez.icu/xzclog/services/trackbacks/433084.html闃呰鍏ㄦ枃

xzc 2018-03-07 11:21 鍙戣〃璇勮
]]>
spark 绱姞鍘嗗彶 + 緇熻鍏ㄩ儴 + 琛岃漿鍒?/title><link>//www.lmlez.icu/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.lmlez.icu/xzclog/archive/2017/10/23/432867.html</guid><wfw:comment>//www.lmlez.icu/xzclog/comments/432867.html</wfw:comment><comments>//www.lmlez.icu/xzclog/archive/2017/10/23/432867.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.lmlez.icu/xzclog/comments/commentRss/432867.html</wfw:commentRss><trackback:ping>//www.lmlez.icu/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.lmlez.icu/xzclog/archive/2017/10/23/432867.html'>闃呰鍏ㄦ枃</a><img src ="//www.lmlez.icu/xzclog/aggbug/432867.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.lmlez.icu/xzclog/" target="_blank">xzc</a> 2017-10-23 22:05 <a href="//www.lmlez.icu/xzclog/archive/2017/10/23/432867.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Spark鍒嗘瀽紿楀彛鍑芥暟 - 4399三国杀ol官网|三国杀传奇武将//www.lmlez.icu/xzclog/archive/2017/10/23/432866.htmlxzcxzcMon, 23 Oct 2017 14:04:00 GMT//www.lmlez.icu/xzclog/archive/2017/10/23/432866.html//www.lmlez.icu/xzclog/comments/432866.html//www.lmlez.icu/xzclog/archive/2017/10/23/432866.html#Feedback0//www.lmlez.icu/xzclog/comments/commentRss/432866.html//www.lmlez.icu/xzclog/services/trackbacks/432866.html闃呰鍏ㄦ枃

xzc 2017-10-23 22:04 鍙戣〃璇勮
]]>
SparkSQL鐩稿叧璇彞鎬葷粨 - 4399三国杀ol官网|三国杀传奇武将//www.lmlez.icu/xzclog/archive/2017/10/23/432865.htmlxzcxzcMon, 23 Oct 2017 13:03:00 GMT//www.lmlez.icu/xzclog/archive/2017/10/23/432865.html//www.lmlez.icu/xzclog/comments/432865.html//www.lmlez.icu/xzclog/archive/2017/10/23/432865.html#Feedback0//www.lmlez.icu/xzclog/comments/commentRss/432865.html//www.lmlez.icu/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鐨勮В鏋愮殑鎵ц嫻佺▼:



]]>