반응형
반응형

PyScript -  Run Python in Your HTML

 

https://pyscript.net/

 

Pyscript.net

Run Python code in your HTML.

pyscript.net

Examples: https://pyscript.net/examples

PyScript

What is PyScript

Summary

PyScript is a Pythonic alternative to Scratch, JSFiddle, and other "easy to use" programming frameworks, with the goal of making the web a friendly, hackable place where anyone can author interesting and interactive applications.

To get started see the getting started tutorial.

For examples see the pyscript folder.

Longer Version

PyScript is a meta project that aims to combine multiple open technologies into a framework that allows users to create sophisticated browser applications with Python. It integrates seamlessly with the way the DOM works in the browser and allows users to add Python logic in a way that feels natural both to web and Python developers.

Try PyScript

To try PyScript, import the appropriate pyscript files to your html page with:

<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>

You can then use PyScript components in your html page. PyScript currently implements the following elements:

  • <py-script>: can be used to define python code that is executable within the web page. The element itself is not rendered to the page and is only used to add logic
  • <py-repl>: creates a REPL component that is rendered to the page as a code editor and allows users to write executable code

Check out the pyscriptjs/examples folder for more examples on how to use it, all you need to do is open them in Chrome.

How to Contribute

Read the contributing guide to learn about our development process, reporting bugs and improvements, creating issues and asking questions.

Resources

https://github.com/pyscript/pyscript

 

GitHub - pyscript/pyscript: Home Page: https://pyscript.net Examples: https://pyscript.net/examples

Home Page: https://pyscript.net Examples: https://pyscript.net/examples - GitHub - pyscript/pyscript: Home Page: https://pyscript.net Examples: https://pyscript.net/examples

github.com

Anaconda Engineering Blog

 

Anaconda Engineering Blog

Sat 30 April 2022 By Fabio Pliger - pandas One of the main reasons I joined Anaconda seven and a half years ago was the company’s commitment to the data science and Python communities by creating tools that enable people to do more with less. Today I'm h

engineering.anaconda.com

 

반응형
반응형

초보자를 위한 파이썬 300제 

https://wikidocs.net/book/922

 

초보자를 위한 파이썬 강의/기초 300 문제 같이 풀어보기

https://www.youtube.com/watch?v=SiK4iYt_7-s&list=PLNPt2ycoheHqhS_OP4XA8nWycWQWnQtki&index=1

 

반응형
반응형
#가상환경 만들기및 실행 

conda create -n jupiter-env python

# To activate this environment, use
#
#     $ conda activate jupiter-env
#
# To deactivate an active environment, use
#
#     $ conda deactivate

conda info --env
# conda environments:
#
base                     C:\ProgramData\Anaconda3
jupiter-env           *  C:\ProgramData\Anaconda3\envs\jupiter-env
main                     C:\ProgramData\Anaconda3\envs\main

(jupiter-env) D:\python\jupyter_data> conda install -y jupyter
(jupiter-env) D:\python\jupyter_data> conda install -y bokeh
(jupiter-env) D:\python\jupyter_data> conda install -y pandas
(jupiter-env) D:\python\jupyter_data> conda install -y matplotlib


(jupiter-env) D:\python\jupyter_data>mkdir notebook
(jupiter-env) D:\python\jupyter_data>cd notebook

# jupyter notebook 실행
(jupiter-env) D:\python\jupyter_data\notebook>jupyter notebook

 

VScode :

이름: Jupyter
ID: ms-toolsai.jupyter
버전: 2022.2.1030672458
게시자: Microsoft VS Marketplace 

링크: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter

Jupyter notebook support, interactive programming and computing that supports Intellisense, debugging and more.

 


# Config 파일 생성 - Jupyter Notebook의 기본 설정
(jupiter-env) D:\python\jupyter_data\notebook>jupyter notebook --generate-config
Writing default config to: C:\Users\pydata\.jupyter\jupyter_notebook_config.py

반응형
반응형

[python] 초보자를 위한 파이썬 300제

 

파이썬 기초 문법을 배웠다고 해서 누구나 프로그래밍에 익숙해지는 것은 아닙니다. 프로그래밍에 익숙해지기까지 많은 문제를 풀어보고 익숙해지는 것이 필요합니다. 파이썬 300제는 파이썬 기초 문법과 관련된 문제들을 제공합니다. 파이썬 300제를 통해 지금까지 배운 기초 문법을 익혀보세요. 문제를 풀다가 막히는 부분은 각 문제 페이지 하단에 있는 유튜브 동영상을 참고하세요.

https://www.youtube.com/watch?v=SiK4iYt_7-s 

https://wikidocs.net/book/922

 

초보자를 위한 파이썬 300제

파이썬 기초 문법을 배웠다고 해서 누구나 프로그래밍에 익숙해지는 것은 아닙니다. 프로그래밍에 익숙해지기까지 많은 문제를 풀어보고 익숙해지는 것이 필요합니다. 파이썬 300제 ...

wikidocs.net

 

반응형
반응형

dictionary 를 json 으로 변환

 

https://docs.python.org/2/library/json.html

 

18.2. json — JSON encoder and decoder — Python 2.7.18 documentation

18.2. json — JSON encoder and decoder JSON (JavaScript Object Notation), specified by RFC 7159 (which obsoletes RFC 4627) and by ECMA-404, is a lightweight data interchange format inspired by JavaScript object literal syntax (although it is not a strict

docs.python.org

import json

dict1 = { 'name' : 'song', 'age' : 10 }

print "dict1 = %s" % dict1
print "dict1 type = %s" % type(dict1)
print "================"

# CONVERT dictionary to json using json.dump
json_val = json.dumps(dict1)


print "json_val = %s" % json_val
print "json_val type = %s" % type(json_val)
반응형
반응형

   
## 시간 표시  ##################################### 
import time
import datetime
now = datetime.datetime.now()

timeserise = time.time()
timeserise = str(int(timeserise))
print(timeserise)
print(now)
#################################################  

#작업하는 경로(위치)가 어디인지 확인
print(os.getcwd())

prePath = "./Project/DataCrawring/"


# CSV 파일로 저장
def dfToCsv(movie_df, num):
    try:
        # 파일이 존재하면 누적저장 mode='a', header=False
        if not os.path.exists(prePath  +'input/movie_data'+str(num) +'.csv'): 
            #movie_df.to_csv((prePath  +'input/movie_data'+str(num) +'.csv'),   header=False, line_terminator=False, encoding='utf-8-sig')        
            movie_df.to_csv((prePath  +'input/movie_data'+str(num) +'.csv'),   index=False, mode='w', header=True, line_terminator=False, encoding='utf-8-sig')
            print("First Save Success~~~ ")        
        else:
            movie_df.to_csv((prePath  +'input/movie_data'+str(num) +'.csv'),   index=False, mode='a', header=False, line_terminator=False, encoding='utf-8-sig')
            print("Add Save Success~~~ ")        
    except:
        print("Error - dfToCsv.....")

pandas 결과값을 csv 파일 형식으로 누적해서 저장하기: to_csv

 

to_csv Append Mode 사용하기

import pandas as pd
import os

# 샘플 데이터 생성
soda = {'상품명': ['콜라', '사이다'], '가격': [2700, 2000]}
df = pd.DataFrame(soda)

# .to_csv 
# 최초 생성 이후 mode는 append
if not os.path.exists('output.csv'):
    df.to_csv('output.csv', index=False, mode='w', encoding='utf-8-sig')
else:
    df.to_csv('output.csv', index=False, mode='a', encoding='utf-8-sig', header=False)

encoding='utf-8' 사용시 한글깨짐 현상이 발생하여, 'utf-8-sig'를 사용하였습니다. utf-8-sig에 관한 더 자세한 내용은 https://stackoverflow.com/questions/25788037/pandas-df-to-csvfile-csv-encode-utf-8-still-gives-trash-characters-for-min를 참고해주세요.

 

 

 

반응형

+ Recent posts