SharePoint의 계산된 열 | 개요
SharePoint에서 계산된 열의 중요성과 목록에서 자동 계산 및 데이터 수집을 수행하는 방법을 알아보세요.
Python 으로 프로그래밍할 때 신뢰할 수 있는 치트 시트를 옆에 두는 것은 게임 체인저가 될 수 있습니다. Python은 단순함과 가독성으로 유명할 수 있지만 광범위한 특징과 기능이 암기하기에 너무 많다는 사실을 부인할 수 없습니다!
Python 치트 시트는 초보자와 숙련된 개발자 모두에게 편리한 참고 자료 역할을 합니다. 다양한 명령, 구문, 데이터 구조 등에 대한 기본 참조 가이드를 제공합니다.
이 가이드 는 특히 초보자에게 압도적일 수 있는 다양한 함수 , 라이브러리, 클래스 및 구문을 탐색하는 데 도움이 되는 Python 치트 시트입니다 .
당신은 구식입니까? 다운로드하여 인쇄하는 것을 선호합니다. Python 학습 여정에 도움이 되는 아래 PDF를 확인하십시오!
목차
Python 구문 기본 사항에 대한 빠른 참조
Python 치트 시트를 시작하기 위해 몇 가지 Python 구문 기본 사항을 살펴보겠습니다. Python 기본 사항을 잘 이해하면 더 복잡한 코드를 작성하기 위한 견고한 기반을 제공할 수 있습니다.
이 참조를 위해 주석 , 변수 , 데이터 유형 , 조건문 , 루프 및 함수 를 포함했습니다 .
1. 댓글
주석은 코드의 중요한 부분입니다. 주석을 통해 사고 과정을 설명하고 코드를 더 읽기 쉽게 만들 수 있기 때문입니다. Python에서는 해시 기호(#)를 사용하여 한 줄 주석을 만들 수 있습니다.
# This is a single-line comment.
여러 줄 주석의 경우 삼중 따옴표(작은따옴표 또는 큰따옴표)를 사용할 수 있습니다.
""" This is a
multi-line
comment. """
2. 변수
Python의 변수는 데이터를 저장하는 데 사용됩니다. 등호(=)를 사용하여 변수에 값을 할당할 수 있습니다.
x = 5
name = "John"
변수 이름은 설명적이어야 하며 공백에 소문자와 밑줄을 사용하는 명명 규칙을 따라야 합니다.
user_age = 25
favorite_color = "blue"
3. 데이터 유형
Python 언어에는 기본적으로 여러 데이터 유형이 내장되어 있습니다. 더 일반적인 것 중 일부는 다음과 같습니다.
텍스트 유형 : str
부울 유형 : 부울
숫자 유형 : int, float, complex
시퀀스 유형 : 목록, 튜플, 범위
없음 유형: Nonetype
Python 객체의 데이터 유형을 찾으려면 type() 함수를 사용할 수 있습니다. 예를 들어:
name = 'jane'
print(type(name))
#Output: 'str'
4. 조건문
Python의 조건문을 사용하면 특정 조건이 충족될 때만 코드를 실행할 수 있습니다. 일반적인 조건문은 ' if ', 'elif ' 및 ' else '입니다.
if condition:
# Code to execute if the condition is true
elif another_condition:
# Code to execute if the another_condition is true
else:
# Code to execute if none of the conditions are true
5. 루프
루프는 코드 블록을 반복적으로 실행하는 데 사용됩니다. Python에는 ' for ' 루프와 ' while ' 루프의 두 가지 유형의 루프가 있습니다.
둘 다 살펴 보겠습니다.
For 루프:
for variable in iterable:
# Code to execute for each element in the iterable
루프 동안:
while condition:
# Code to execute while the condition is true
이 루프 내에서 조건문과 제어문을 사용하여 프로그램의 흐름을 제어할 수 있습니다.
6. 기능
Python의 함수는 특정 작업을 수행하는 코드 블록입니다. ' def ' 키워드 다음에 함수 이름과 입력 매개변수를 포함하는 괄호를 사용하여 함수를 정의할 수 있습니다 .
def function_name(parameters):
# Code to execute
return result
함수를 호출하려면 함수 이름 다음에 필요한 인수를 포함하는 괄호를 사용하십시오.
function_name(arguments)
이제 Python 기본 사항을 살펴보았으므로 다음 섹션에서 좀 더 고급 주제로 이동하겠습니다.
Python 데이터 구조에 대한 빠른 참조
다음 Python 치트 시트에서는 Python에서 가장 일반적으로 사용되는 데이터 구조에 대해 설명합니다. 이러한 데이터 구조는 프로그래밍 프로젝트에서 데이터를 관리하고 구성하는 데 필수적입니다.
Python에는 고급 개발자가 사용할 수 있는 많은 데이터 구조가 있습니다. 그러나 Lists , Tuples , Sets 및 Dictionaries 에 중점을 둘 것입니다 .
1. 목록
Python의 목록은 변경 가능하고 순서가 지정된 요소 시퀀스입니다. 목록을 만들려면 대괄호를 사용하고 요소를 쉼표로 구분합니다.
Python 목록은 문자열, 정수, 부울 등과 같은 다양한 데이터 유형을 보유할 수 있습니다. 다음은 Python 목록으로 수행할 수 있는 작업의 몇 가지 예입니다.
목록 만들기:
my_list = [1, 2, 3]
액세스 요소:
my_list[0]
요소 추가:
my_list.append(4)
2. 튜플
튜플은 목록과 비슷하지만 변경할 수 없습니다. 즉, 일단 생성된 요소는 변경할 수 없습니다. 괄호를 사용하고 요소를 쉼표로 구분하여 튜플을 만들 수 있습니다.
다음은 튜플 작업의 몇 가지 예입니다.
튜플을 만듭니다.
my_tuple = (1, 2, 3)
액세스 요소:
my_tuple[0] #Output: 1
3. 세트
집합은 고유한 요소의 정렬되지 않은 모음입니다. set() 함수 또는 중괄호를 사용하여 집합을 만들 수 있습니다.
또한 고유한 한 다양한 데이터 유형을 보유할 수 있습니다. 다음은 설정 작업의 몇 가지 예입니다.
세트 만들기:
my_set = {1, 2, 3}
요소 추가:
my_set.add(4)
요소 제거:
my_set.remove(1)
4. 사전
사전은 키가 고유한 키-값 쌍의 정렬되지 않은 모음입니다. 중괄호를 사용하고 키와 값을 콜론으로 구분하여 사전을 만들 수 있습니다. 다음은 사전 작업의 몇 가지 예입니다.
사전 만들기:
my_dict = {'key1': 'value1', 'key2': 'value2'}
액세스 요소:
my_dict['key1'] #Output:'value1'
키-값 쌍을 추가합니다.
my_dict['key3'] = 'value3'
키-값 쌍을 제거합니다.
del my_dict['key1']
Python 프로젝트에서 이러한 데이터 구조를 연습하고 탐색하여 사용에 더 능숙해지십시오! 다음으로 파일 I/O 작업에 대한 참조를 제공합니다.
Quick Reference for Python File I/O
In this section of the Python cheat sheet, we’ll focus on some common tasks related to working with files in Python, such as reading, writing, and appending data.
1. Reading Files
To read a file, you first need to open it using the built-in open() function, with the mode parameter set to ‘r‘ for reading:
file_obj = open('file_path', 'r')
Now that your file is open, you can use different methods to read its content:
read(): Reads the entire content of the file.
readline(): Reads a single line from the file.
readlines(): Returns a list of all lines in the file.
It’s important to remember to close the file once you’ve finished working with it:
file_obj.close()
Alternatively, you can use the with statement, which automatically closes the file after the block of code completes:
with open('file_path', 'r') as file_obj:
content = file_obj.read()
2. Writing Files
To create a new file or overwrite an existing one, open the file with mode ‘w‘:
file_obj = open('file_path', 'w')
Write data to the file using the write() method:
file_obj.write('This is a line of text.')
Don’t forget to close the file:
file_obj.close()
Again, consider using the with statement for a more concise and safer way to handle files:
with open('file_path', 'w') as file_obj:
file_obj.write('This is a line of text.')
3. Appending to Files
To add content to an existing file without overwriting it, open the file with mode ‘a‘:
file_obj = open('file_path', 'a')
Use the write() method to append data to the file:
file_obj.write('This is an extra line of text.')
And, as always, close the file when you’re done:
file_obj.close()
For a more efficient and cleaner approach, use the with statement:
with open('file_path', 'a') as file_obj:
file_obj.write('This is an extra line of text.')
By following these steps and examples, you can efficiently navigate file operations in your Python applications. Remember to always close your files after working with them to avoid potential issues and resource leaks!
In the next section, we provide a reference for error handling in Python.
Quick Reference for Error Handling in Python
In this section, you’ll learn about error handling in Python, which plays a crucial role in preventing the abrupt termination of your programs when it encounters an error.
We’ll cover the following sub-sections: Try and Except, Finally, and Raising Exceptions.
1. Try and Except
To handle exceptions in your code, you can use the try and except blocks. The try block contains the code that might raise an error, whereas the except block helps you handle that exception, ensuring your program continues running smoothly.
Here’s an example:
try:
quotient = 5 / 0
except ZeroDivisionError as e:
print("Oops! You're trying to divide by zero.")
In this case, the code inside the try block will raise a ZeroDivisionError exception. Since we have an except block to handle this specific exception, it will catch the error and print the message to alert you about the issue.
2. Finally
The finally block is used when you want to ensure that a specific block of code is executed, no matter the outcome of the try and except blocks. This is especially useful for releasing resources or closing files or connections, even if an exception occurs, ensuring a clean exit.
Here’s an example:
try:
# Your code here
except MyException as e:
# Exception handling
finally:
print("This will run no matter the outcome of the try and except blocks.")
3. Raising Exceptions
You can also raise custom exceptions in your code to trigger error handling when specific conditions are met. To do this, you can use the raise statement followed by the exception you want to raise (either built-in or custom exception).
For instance:
def validate_age(age):
if age < 0:
raise ValueError("Age cannot be a negative value.")
try:
validate_age(-3)
except ValueError as ve:
print(ve)
In this example, we’ve defined a custom function to validate an age value. If the provided age is less than zero, we raise a ValueError with a custom message. When calling this function, you should wrap it in a try-except block to handle the exception properly.
Next, we’re going to provide a quick reference for popular Python modules and packages. Let’s go!
Quick Reference for Python Modules and Packages
This section of our cheat sheet is for Python packages and modules, which are essential for structuring and organizing your code cleanly and efficiently.
You’ll learn about importing modules and creating packages.
1. Importing Modules
Modules in Python are files containing reusable code, such as functions, classes, or variables. Python offers several modules and packages for different tasks like data science, machine learning, robotics, etc.
To use a module’s contents in your code, you need to import it first. Here are a few different ways to import a module:
import : This imports the entire module, and you can access its contents using the syntax ‘module_name.content_name.’
For example:
import random
c = random.ranint()
from import : This imports a specific content (function or variable) from the module, and you can use it directly without referencing the module name.
from math import sin
c = sin(1.57)
from import *: This imports all contents of the module. Be careful with this method as it can lead to conflicts if different modules have contents with the same name.
Some commonly used built-in Python modules include:
math: Provides mathematical functions and constants
random: Generates random numbers and provides related functions
datetime: Handles date and time operations
os: Interacts with the operating system and manages files and directories
2. Creating Packages
Packages in Python are collections of related modules. They help you organize your code into logical and functional units. To create a package:
Create a new directory with the desired package name.
Add an empty file named init.py to the directory. This file indicates to Python that the directory should be treated as a package.
Add your module files (with the .py extension) to the directory.
Now, you can import the package or its modules into your Python scripts. To import a module from a package, use the syntax:
import
Structure your code with modules and packages to make it more organized and maintainable. This will also make it easier for you and others to navigate and comprehend your codebase.
In the next section, we provide a reference for object-oriented programming concepts in Python.
Quick Reference for Object-Oriented Programming in Python
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of “objects“, which can contain data and code.
The data is in the form of fields, often known as attributes or properties, and the code is in the form of procedures, often known as methods.
In this section of the cheat sheet, we’ll delve into the fundamental concepts of OOP in Python, including classes, inheritance, and encapsulation.
1. Classes
A class is a blueprint for creating objects. It defines the data (attributes) and functionality (methods) of the objects. To begin creating your own class, use the “class” keyword followed by the class name:
class ClassName:
# Class attributes and methods
To add attributes and methods, simply define them within the class block. For example:
class Dog:
def __init__(self, name, breed):
self.name = name
self.breed = breed
def bark(self):
print("Woof!")
이 예제에서는 이름과 품종으로 새 Dog 개체를 만들 수 있으며 " Woof!" 를 인쇄하는 bark 메서드가 있습니다. "라고 부를 때.
2. 상속
상속을 통해 한 클래스가 다른 클래스의 특성과 메서드를 상속할 수 있으므로 코드 재사용성과 모듈성이 가능합니다. 상속되는 클래스를 하위 클래스 또는 파생 클래스라고 하고 상속되는 클래스를 기본 클래스 또는 수퍼 클래스라고 합니다.
상속을 구현하려면 서브클래스 이름 뒤에 괄호 안에 슈퍼클래스 이름을 추가합니다.
class SubclassName(SuperclassName):
# Subclass attributes and methods
예를 들어 "Dog" 클래스에서 "Poodle" 하위 클래스를 만들 수 있습니다.
class Poodle(Dog):
def show_trick(self):
print("The poodle does a trick.")
Poodle 개체는 이제 자체 show_trick 메서드뿐만 아니라 Dog 클래스의 모든 속성과 메서드를 갖게 됩니다.
3. 캡슐화
캡슐화는 단일 단위(이 경우 개체) 내에서 해당 데이터에 대해 작동하는 데이터 및 메서드를 래핑하는 방법입니다. 이것은 개체의 내부 구현과 외부 인터페이스 사이의 명확한 분리를 촉진합니다.
Python은 이름 맹글링을 사용하여 속성 이름에 이중 밑줄 접두사를 추가하여 클래스 구성원에 대한 캡슐화를 달성하여 겉보기에 비공개로 만듭니다.
class Example:
def __init__(self):
self.__private_attribute = "I'm private!"
def __private_method(self):
print("You can't see me!")
여전히 Python에서 이러한 개인 멤버에 기술적으로 액세스할 수 있지만 캡슐화 원칙을 위반하므로 그렇게 하지 않는 것이 좋습니다.
Python 프로그램에서 클래스, 상속 및 캡슐화를 이해하고 구현함으로써 OOP의 기능과 유연성을 활용하여 깨끗하고 모듈식이며 재사용 가능한 코드를 만들 수 있습니다.
치트 시트의 마지막 섹션에서는 인기 있는 Python 라이브러리 4개에 대한 빠른 참조를 제공합니다.
유용한 Python 라이브러리 4개
여러 Python 라이브러리를 통해 다양한 작업을 수행 하거나 수학, 데이터 과학, 웹 스크래핑 등과 같은 다양한 주제에 대한 도구를 얻을 수 있습니다.
이 섹션에서는 NumPy , Pandas , Requests 및 Beautiful Soup 라이브러리에 대해 간략하게 설명합니다 .
1. 넘파이
NumPy 는 수학 및 과학 컴퓨팅을 위한 인기 있는 Python 라이브러리입니다. 강력한 N차원 배열 개체를 사용하여 다음과 같은 광범위한 수학적 연산을 처리할 수 있습니다.
기본 수학 함수
선형 대수학
푸리에 분석
난수 생성
NumPy의 효율적인 배열 조작은 수치 계산이 필요한 프로젝트에 특히 적합합니다.
2. 팬더
Pandas는 구조화된 데이터 작업에 사용할 수 있는 강력한 데이터 분석 및 조작 라이브러리입니다. 또한 데이터 처리를 위해 제공되는 다양한 도구로 인해 데이터 과학 커뮤니티에서 매우 인기가 있습니다.
일부 기능은 다음과 같습니다.
Series(1D) 및 DataFrame(2D)과 같은 데이터 구조
데이터 정리 및 준비
통계 분석
시계열 기능
Pandas를 활용하면 CSV, Excel 및 SQL 데이터베이스와 같은 다양한 형식의 데이터를 쉽게 가져오고, 분석하고, 조작할 수 있습니다.
Pandas에 관심이 있는 경우 Pandas를 사용하여 시계열 데이터를 리샘플링하여 분석을 개선하는 방법 에 대한 비디오를 확인할 수 있습니다 .
3. 요청사항
요청 라이브러리 는 Python에서 HTTP 요청을 처리하는 프로세스를 단순화합니다. 이 라이브러리를 사용하면 GET, POST 및 DELETE와 같은 HTTP 요청을 쉽게 보내고 받을 수 있습니다.
몇 가지 주요 기능은 다음과 같습니다.
웹 페이지에서 리디렉션 및 다음 링크 처리
간단한 Python 라이브러리를 통해 헤더, 양식 데이터 및 쿼리 매개변수 추가
쿠키 및 세션 관리
요청을 사용하면 다양한 웹 서비스 및 API와 빠르고 효율적으로 상호 작용할 수 있습니다.
4. 아름다운 수프
Beautiful Soup은 HTML 및 XML 문서에서 데이터를 추출할 수 있는 웹 스크래핑용 Python 라이브러리입니다. 주요 기능 중 일부는 다음과 같습니다.
특정 태그 또는 CSS 클래스 검색
구문 분석된 트리 탐색 및 수정
태그 속성 기반 관련 정보 추출
Beautiful Soup을 Requests와 함께 사용하면 다양한 웹사이트에서 정보를 수집하는 강력한 웹 스크래핑 애플리케이션을 만들 수 있습니다.
마지막 생각들
이것으로 우리는 Python 차선으로의 빠른 여행을 마칠 것입니다. 이 치트 시트는 Python의 주요 기능과 명령을 빠르게 상기해야 할 때를 위한 포켓 가이드이자 신뢰할 수 있는 조수입니다.
우리의 목록은 완전하지는 않지만 견고한 시작이며 구축할 수 있는 토대입니다. 그러니 계속해서 북마크하고, 인쇄하고, 벽에 붙입니다. 코딩할 때 가까이에 두기만 하면 됩니다. 행복한 프로그래밍!
SharePoint에서 계산된 열의 중요성과 목록에서 자동 계산 및 데이터 수집을 수행하는 방법을 알아보세요.
컬렉션 변수를 사용하여 Power Apps에서 변수 만드는 방법 및 유용한 팁에 대해 알아보세요.
Microsoft Flow HTTP 트리거가 수행할 수 있는 작업과 Microsoft Power Automate의 예를 사용하여 이를 사용하는 방법을 알아보고 이해하십시오!
Power Automate 흐름 및 용도에 대해 자세히 알아보세요. 다양한 작업 및 시나리오에 사용할 수 있는 다양한 유형의 흐름에 대해 설명합니다.
조건이 충족되지 않는 경우 흐름에서 작업을 종료하는 Power Automate 종료 작업 컨트롤을 올바르게 사용하는 방법을 알아봅니다.
PowerApps 실행 기능에 대해 자세히 알아보고 자신의 앱에서 바로 웹사이트, 전화, 이메일 및 기타 앱과 같은 기타 서비스를 실행하십시오.
타사 애플리케이션 통합과 관련하여 Power Automate의 HTTP 요청이 작동하는 방식을 배우고 이해합니다.
Power Automate Desktop에서 Send Mouse Click을 사용하는 방법을 알아보고 이것이 어떤 이점을 제공하고 흐름 성능을 개선하는지 알아보십시오.
PowerApps 변수의 작동 방식, 다양한 종류, 각 변수가 앱에 기여할 수 있는 사항을 알아보세요.
이 자습서에서는 Power Automate를 사용하여 웹 또는 데스크톱에서 작업을 자동화하는 방법을 알려줍니다. 데스크톱 흐름 예약에 대한 포괄적인 가이드를 제공합니다.