How can I merge two Python dictionaries in a single expression? For dictionaries x and y, z becomes a merged dictionary with values from y replacing those from x. In Python 3.5 or greater: x = {'a':'1', 'b':'2', 'c':'3'} y = {'d':'4', 'e':'5', 'f':'6'} z = {**x, **y} print(z) {'a': '1', 'b': '2', 'c': '3', 'd': '4', 'e': '5', 'f': '6'} Another example: w = {'foo': 'bar', 'baz': 'qux', **y} # mer..
#!/bin/sh ######################################################### # "DaemonManager.sh" ######################################################### if [ -f ~/.bashrc ]; then . ~/.bashrc PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH export PATH=/usr/local/anaconda3-4.1.0/bin:/usr/local/lib/:$PATH fi WORKDIR=~/TEST/BaseUpdateDaemon DAEMON=daemon.py LOG=~/TEST/log/daemon.log function do_start() ..
1. uic library를 이용하는 법 import sys from PyQt5 import QtWidgets ,uic class Form(QtWidgets.QDialog): def __init__(self): super().__init__() self.ui = uic.loadUi("test-form.ui") #ui 파일 불러오기 self.ui.show() if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) w = Form() sys.exit(app.exec()) 2. UI File을 Py File로 변환하는 법 qt designer 에서 form 작성. %Anaconda3%\Library\bin\designer.exe 예) C:\Prog..
Python 3.x 에서 Dictionary를 value가 큰 순으로 정렬하는 여러가지 방법 def dict_val(x): return x[1] x = {"python": 2, "blah": 4, "alice": 3} #일반적인방법 sorted_x1 = sorted(x.items(), key=dict_val, reverse=True) print('sorted_x1',sorted_x1) #lambda를 이용하는 방법 sorted_x2 = sorted(x.items(), key=lambda t: t[1], reverse=True) print('sorted_x2',sorted_x2) #zip을 이용하는 방법 sorted_x3 = sorted(zip(x.values(), x.keys()), reverse=Tru..